use of io.openlineage.client.OpenLineage.RunFacet in project OpenLineage by OpenLineage.
the class LogicalPlanRunFacetBuilderTest method testBuild.
@Test
public void testBuild() {
LogicalPlanRunFacetBuilder builder = new LogicalPlanRunFacetBuilder(OpenLineageContext.builder().sparkContext(sparkContext).openLineage(new OpenLineage(OpenLineageClient.OPEN_LINEAGE_CLIENT_URI)).queryExecution(queryExecution).build());
Map<String, RunFacet> facetMap = new HashMap<>();
builder.build(new SparkListenerSQLExecutionEnd(1L, 1L), facetMap::put);
assertThat(facetMap).hasEntrySatisfying("spark.logicalPlan", facet -> assertThat(facet).hasFieldOrPropertyWithValue("plan", queryExecution.optimizedPlan().toJSON()));
}
use of io.openlineage.client.OpenLineage.RunFacet in project OpenLineage by OpenLineage.
the class SparkVersionFacetBuilderTest method testBuild.
@Test
public void testBuild() {
SparkVersionFacetBuilder builder = new SparkVersionFacetBuilder(OpenLineageContext.builder().sparkContext(sparkContext).openLineage(new OpenLineage(OpenLineageClient.OPEN_LINEAGE_CLIENT_URI)).build());
Map<String, RunFacet> runFacetMap = new HashMap<>();
builder.build(new SparkListenerSQLExecutionEnd(1, 1L), runFacetMap::put);
assertThat(runFacetMap).hasEntrySatisfying("spark_version", facet -> assertThat(facet).isInstanceOf(SparkVersionFacet.class).hasFieldOrPropertyWithValue("sparkVersion", sparkContext.version()));
}
use of io.openlineage.client.OpenLineage.RunFacet in project OpenLineage by OpenLineage.
the class ErrorFacetBuilderTest method testBuildErrorFacet.
@Test
public void testBuildErrorFacet() {
JobFailed failure = new JobFailed(new TestException("The test exception message"));
SparkListenerJobEnd event = new SparkListenerJobEnd(1, 1L, failure);
ErrorFacetBuilder builder = new ErrorFacetBuilder();
assertThat(builder.isDefinedAt(event)).isTrue();
Map<String, RunFacet> runFacetMap = new HashMap<>();
builder.build(event, runFacetMap::put);
assertThat(runFacetMap).hasEntrySatisfying("spark.exception", facet -> assertThat(facet).isInstanceOf(ErrorFacet.class).extracting("message").isEqualTo(failure.exception().getMessage()));
}
use of io.openlineage.client.OpenLineage.RunFacet in project OpenLineage by OpenLineage.
the class InternalEventHandlerFactory method createRunFacetBuilders.
@Override
public Collection<CustomFacetBuilder<?, ? extends RunFacet>> createRunFacetBuilders(OpenLineageContext context) {
Builder<CustomFacetBuilder<?, ? extends RunFacet>> listBuilder;
listBuilder = ImmutableList.<CustomFacetBuilder<?, ? extends RunFacet>>builder().addAll(generate(eventHandlerFactories, factory -> factory.createRunFacetBuilders((context)))).add(new ErrorFacetBuilder(), new LogicalPlanRunFacetBuilder(context), new SparkVersionFacetBuilder(context));
if (DatabricksEnvironmentFacetBuilder.isDatabricksRuntime()) {
listBuilder.add(new DatabricksEnvironmentFacetBuilder(context));
}
return listBuilder.build();
}
Aggregations