forked from OpenLineage/OpenLineage
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Sdf Transport Support for v1.4.1-SNAPSHOT #1
Open
akbog
wants to merge
3
commits into
main
Choose a base branch
from
bog/latest-release
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=1.4.1 | ||
version=1.4.1-SNAPSHOT |
21 changes: 21 additions & 0 deletions
21
client/java/src/main/java/io/openlineage/client/transports/SdfConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
/* Copyright 2018-2023 contributors to the OpenLineage project | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.openlineage.client.transports; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.With; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString | ||
@With | ||
public final class SdfConfig implements TransportConfig { | ||
@Getter @Setter private String output; | ||
} |
52 changes: 52 additions & 0 deletions
52
client/java/src/main/java/io/openlineage/client/transports/SdfTransport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
/* Copyright 2018-2023 contributors to the OpenLineage project | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.openlineage.client.transports; | ||
|
||
import io.openlineage.client.OpenLineage; | ||
import io.openlineage.client.OpenLineageClientUtils; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.time.format.DateTimeFormatter; | ||
import lombok.NonNull; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* Writes a new file for each Openlineage. Files are labeled with | ||
* {run_id}_{yyyy_MM_dd_HH_mm_ss}.json | ||
*/ | ||
@Slf4j | ||
public class SdfTransport extends Transport { | ||
|
||
Path output_dir; | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss"); | ||
|
||
public SdfTransport(@NonNull final SdfConfig sdfConfig) { | ||
super(Type.SDF); | ||
output_dir = Paths.get(sdfConfig.getOutput()); | ||
} | ||
|
||
@Override | ||
public void emit(OpenLineage.RunEvent runEvent) { | ||
// if DEBUG loglevel is enabled, this will double-log even due to OpenLineageClient also logging | ||
emit( | ||
OpenLineageClientUtils.toJson(runEvent), | ||
runEvent.getRun().getRunId().toString(), | ||
runEvent.getEventTime().format(formatter)); | ||
} | ||
|
||
public void emit(String eventAsJson, String runId, String suffix) { | ||
Path path_to_write = output_dir.resolve(runId + "_" + suffix + ".json"); | ||
try { | ||
Files.write(path_to_write, eventAsJson.getBytes(StandardCharsets.UTF_8)); | ||
log.info("emitted event: " + eventAsJson); | ||
} catch (IOException | IllegalArgumentException e) { | ||
log.error("Writing event to a file {} failed: {}", path_to_write.toString(), e); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
client/java/src/main/java/io/openlineage/client/transports/SdfTransportBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
/* Copyright 2018-2023 contributors to the OpenLineage project | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.openlineage.client.transports; | ||
|
||
public class SdfTransportBuilder implements TransportBuilder { | ||
|
||
@Override | ||
public TransportConfig getConfig() { | ||
return new SdfConfig(); | ||
} | ||
|
||
@Override | ||
public Transport build(TransportConfig config) { | ||
return new SdfTransport((SdfConfig) config); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return "sdf"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
client/java/src/test/java/io/openlineage/client/transports/SdfTransportTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
/* Copyright 2018-2023 contributors to the OpenLineage project | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.openlineage.client.transports; | ||
|
||
import io.openlineage.client.OpenLineage; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.nio.file.DirectoryStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.time.ZonedDateTime; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import lombok.SneakyThrows; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class SdfTransportTest { | ||
|
||
private static final String FILE_LOCATION_DIR = "/tmp/openlineage_sdf_transport_test"; | ||
|
||
SdfConfig sdfConfig; | ||
Transport transport; | ||
|
||
@BeforeEach | ||
@SneakyThrows | ||
public void beforeEach() { | ||
FileUtils.deleteDirectory(new File(FILE_LOCATION_DIR)); | ||
|
||
sdfConfig = new SdfConfig(); | ||
sdfConfig.setOutput(FILE_LOCATION_DIR); | ||
transport = new SdfTransport(sdfConfig); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void transportWritesToFiles() { | ||
transport.emit( | ||
new OpenLineage(URI.create("http://test.producer")) | ||
.newRunEventBuilder() | ||
.job(new OpenLineage.JobBuilder().name("test-job").namespace("test-ns").build()) | ||
.run(new OpenLineage.RunBuilder().runId(UUID.randomUUID()).build()) | ||
.eventTime(ZonedDateTime.now()) | ||
.build()); | ||
Path output_path = Paths.get(FILE_LOCATION_DIR); | ||
|
||
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(output_path)) { | ||
Path firstFile = directoryStream.iterator().next(); | ||
if (Files.exists(firstFile)) { | ||
List<String> lines = Files.readAllLines(firstFile); | ||
|
||
// Print the contents of the first file | ||
for (String line : lines) { | ||
System.out.println(line); | ||
} | ||
} else { | ||
System.out.println("No files found in the directory."); | ||
} | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Instructions for Building the OpenLineage Jar | ||
|
||
Note: Please run these instructions within an Intellij IDE, which helps to configure / install all of the gradle build dependencies & jars automatically | ||
|
||
To install a clean jar, start by cleaning up your local maven cache: | ||
|
||
```bash | ||
sudo rm -r ~/.m2/repository | ||
``` | ||
|
||
Next, navigate to `client/java` and run: | ||
|
||
```bash | ||
./gradlew clean build publishToMavenLocal | ||
``` | ||
|
||
Once that completes successfully, go ahead and navigate to `integration/sql/iface-java` and run: | ||
|
||
``` | ||
cargo clean | ||
./script/compile.sh | ||
./script/build.sh | ||
``` | ||
|
||
|
||
Lastly, navigate to `integration/spark`. Run: | ||
|
||
``` | ||
./gradlew clean --refresh-dependencies | ||
``` | ||
|
||
|
||
You may run into an error if the `gradle.properties` defined version has a `-SNAPSHOT` suffix. Remove it, run the above command, and before proceeding further,ensure that you have added it back. Your `gradle.properties` should look as follows: | ||
|
||
```gradle.properties | ||
jdk8.build=true | ||
version={YOUR-VERSION-NUMBER}-SNAPSHOT | ||
spark.version=3.5.0 | ||
org.gradle.jvmargs=-Xmx1G | ||
``` | ||
|
||
Finally run: | ||
|
||
``` | ||
./gradlew build -x test | ||
``` | ||
|
||
*Note:* This currently excludes tests as some are failing | ||
|
||
The jar should be available at: `intergation/spark/build/libs/openlineage-spark-1.4.1-SNAPSHOT.jar` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
jdk8.build=true | ||
version=1.4.1 | ||
version=1.4.1-SNAPSHOT | ||
spark.version=3.5.0 | ||
org.gradle.jvmargs=-Xmx1G |
95 changes: 95 additions & 0 deletions
95
integration/spark/shared/facets/spark/v1/analyzed-logical-plan-facet.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"definitions": { | ||
"Run": { | ||
"properties": { | ||
"facets": { | ||
"properties": { | ||
"spark.analyzedLogicalPlan": { | ||
"$ref": "#/definitions/AnalyzedLogicalPlanRunFacet" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"AnalyzedLogicalPlanRunFacet": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"children": { | ||
"type": "array", | ||
"items": { | ||
"anyOf": [ | ||
{ | ||
"$ref": "#/definitions/AnalyzedLogicalPlanRunFacet" | ||
}, | ||
{ | ||
"$ref": "#/definitions/InsertIntoHadoopFsRelationCommand" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"additionalProperties": true | ||
}, | ||
"InsertIntoHadoopFsRelationCommand": { | ||
"type": "object", | ||
"properties":{ | ||
"outputPath": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": true | ||
}, | ||
"LogicalRelation": { | ||
"type": "object", | ||
"properties":{ | ||
"relation": { | ||
"anyOf": [ | ||
{ | ||
"$ref": "#/definitions/HadoopFsRelation" | ||
}, | ||
{ | ||
"$ref": "#/definitions/JDBCRelation" | ||
} | ||
] | ||
} | ||
}, | ||
"additionalProperties": true | ||
}, | ||
"HadoopFsRelation": { | ||
"type": "object", | ||
"properties":{ | ||
"relation": { | ||
"type": "object", | ||
"properties": { | ||
"location": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": true | ||
}, | ||
"JDBCRelation": { | ||
"type": "object", | ||
"properties":{ | ||
"relation": { | ||
"type": "object", | ||
"properties": { | ||
"jdbcOptions": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": true | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we catch all exceptions also?