Search in sources :

Example 1 with RunFacet

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()));
}
Also used : SparkListenerSQLExecutionEnd(org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd) HashMap(java.util.HashMap) OpenLineage(io.openlineage.client.OpenLineage) RunFacet(io.openlineage.client.OpenLineage.RunFacet) Test(org.junit.jupiter.api.Test)

Example 2 with RunFacet

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()));
}
Also used : SparkListenerSQLExecutionEnd(org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd) HashMap(java.util.HashMap) OpenLineage(io.openlineage.client.OpenLineage) RunFacet(io.openlineage.client.OpenLineage.RunFacet) Test(org.junit.jupiter.api.Test)

Example 3 with RunFacet

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()));
}
Also used : ErrorFacet(io.openlineage.spark.agent.facets.ErrorFacet) JobFailed(org.apache.spark.scheduler.JobFailed) SparkListenerJobEnd(org.apache.spark.scheduler.SparkListenerJobEnd) HashMap(java.util.HashMap) RunFacet(io.openlineage.client.OpenLineage.RunFacet) Test(org.junit.jupiter.api.Test)

Example 4 with RunFacet

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();
}
Also used : Spliterators(java.util.Spliterators) InputDataset(io.openlineage.client.OpenLineage.InputDataset) OutputDatasetFacet(io.openlineage.client.OpenLineage.OutputDatasetFacet) Function(java.util.function.Function) SparkVersionFacetBuilder(io.openlineage.spark.agent.facets.builder.SparkVersionFacetBuilder) ImmutableList(com.google.common.collect.ImmutableList) OutputDataset(io.openlineage.client.OpenLineage.OutputDataset) ErrorFacetBuilder(io.openlineage.spark.agent.facets.builder.ErrorFacetBuilder) OutputStatisticsOutputDatasetFacetBuilder(io.openlineage.spark.agent.facets.builder.OutputStatisticsOutputDatasetFacetBuilder) JobFacet(io.openlineage.client.OpenLineage.JobFacet) DatabricksEnvironmentFacetBuilder(io.openlineage.spark.agent.facets.builder.DatabricksEnvironmentFacetBuilder) StreamSupport(java.util.stream.StreamSupport) LogicalPlanRunFacetBuilder(io.openlineage.spark.agent.facets.builder.LogicalPlanRunFacetBuilder) LogicalPlan(org.apache.spark.sql.catalyst.plans.logical.LogicalPlan) PartialFunction(scala.PartialFunction) OpenLineageContext(io.openlineage.spark.api.OpenLineageContext) Collection(java.util.Collection) InputDatasetFacet(io.openlineage.client.OpenLineage.InputDatasetFacet) ServiceLoader(java.util.ServiceLoader) DatasetFacet(io.openlineage.client.OpenLineage.DatasetFacet) Collectors(java.util.stream.Collectors) List(java.util.List) OpenLineageEventHandlerFactory(io.openlineage.spark.api.OpenLineageEventHandlerFactory) CustomFacetBuilder(io.openlineage.spark.api.CustomFacetBuilder) Builder(com.google.common.collect.ImmutableList.Builder) Spliterator(java.util.Spliterator) RunFacet(io.openlineage.client.OpenLineage.RunFacet) ErrorFacetBuilder(io.openlineage.spark.agent.facets.builder.ErrorFacetBuilder) LogicalPlanRunFacetBuilder(io.openlineage.spark.agent.facets.builder.LogicalPlanRunFacetBuilder) DatabricksEnvironmentFacetBuilder(io.openlineage.spark.agent.facets.builder.DatabricksEnvironmentFacetBuilder) RunFacet(io.openlineage.client.OpenLineage.RunFacet) CustomFacetBuilder(io.openlineage.spark.api.CustomFacetBuilder) SparkVersionFacetBuilder(io.openlineage.spark.agent.facets.builder.SparkVersionFacetBuilder)

Aggregations

RunFacet (io.openlineage.client.OpenLineage.RunFacet)4 HashMap (java.util.HashMap)3 Test (org.junit.jupiter.api.Test)3 OpenLineage (io.openlineage.client.OpenLineage)2 SparkListenerSQLExecutionEnd (org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd)2 ImmutableList (com.google.common.collect.ImmutableList)1 Builder (com.google.common.collect.ImmutableList.Builder)1 DatasetFacet (io.openlineage.client.OpenLineage.DatasetFacet)1 InputDataset (io.openlineage.client.OpenLineage.InputDataset)1 InputDatasetFacet (io.openlineage.client.OpenLineage.InputDatasetFacet)1 JobFacet (io.openlineage.client.OpenLineage.JobFacet)1 OutputDataset (io.openlineage.client.OpenLineage.OutputDataset)1 OutputDatasetFacet (io.openlineage.client.OpenLineage.OutputDatasetFacet)1 ErrorFacet (io.openlineage.spark.agent.facets.ErrorFacet)1 DatabricksEnvironmentFacetBuilder (io.openlineage.spark.agent.facets.builder.DatabricksEnvironmentFacetBuilder)1 ErrorFacetBuilder (io.openlineage.spark.agent.facets.builder.ErrorFacetBuilder)1 LogicalPlanRunFacetBuilder (io.openlineage.spark.agent.facets.builder.LogicalPlanRunFacetBuilder)1 OutputStatisticsOutputDatasetFacetBuilder (io.openlineage.spark.agent.facets.builder.OutputStatisticsOutputDatasetFacetBuilder)1 SparkVersionFacetBuilder (io.openlineage.spark.agent.facets.builder.SparkVersionFacetBuilder)1 CustomFacetBuilder (io.openlineage.spark.api.CustomFacetBuilder)1