Search in sources :

Example 1 with SparkListenerSQLExecutionEnd

use of org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd in project OpenLineage by OpenLineage.

the class LogicalPlanRunFacetBuilderTest method testIsNotDefinedWithoutQueryExecution.

@Test
public void testIsNotDefinedWithoutQueryExecution() {
    LogicalPlanRunFacetBuilder builder = new LogicalPlanRunFacetBuilder(OpenLineageContext.builder().sparkContext(sparkContext).openLineage(new OpenLineage(OpenLineageClient.OPEN_LINEAGE_CLIENT_URI)).build());
    assertThat(builder.isDefinedAt(new SparkListenerSQLExecutionStart(1L, "", "", "", null, 1L))).isFalse();
    assertThat(builder.isDefinedAt(new SparkListenerSQLExecutionEnd(1L, 1L))).isFalse();
    assertThat(builder.isDefinedAt(new SparkListenerJobEnd(1, 1L, JobSucceeded$.MODULE$))).isFalse();
    assertThat(builder.isDefinedAt(new SparkListenerJobStart(1, 1L, Seq$.MODULE$.empty(), new Properties()))).isFalse();
}
Also used : SparkListenerSQLExecutionStart(org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionStart) SparkListenerSQLExecutionEnd(org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd) SparkListenerJobEnd(org.apache.spark.scheduler.SparkListenerJobEnd) SparkListenerJobStart(org.apache.spark.scheduler.SparkListenerJobStart) OpenLineage(io.openlineage.client.OpenLineage) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 2 with SparkListenerSQLExecutionEnd

use of org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd in project OpenLineage by OpenLineage.

the class LogicalPlanRunFacetBuilderTest method testIsDefined.

@Test
public void testIsDefined() {
    LogicalPlanRunFacetBuilder builder = new LogicalPlanRunFacetBuilder(OpenLineageContext.builder().sparkContext(sparkContext).openLineage(new OpenLineage(OpenLineageClient.OPEN_LINEAGE_CLIENT_URI)).queryExecution(queryExecution).build());
    assertThat(builder.isDefinedAt(new SparkListenerSQLExecutionStart(1L, "", "", "", null, 1L))).isTrue();
    assertThat(builder.isDefinedAt(new SparkListenerSQLExecutionEnd(1L, 1L))).isTrue();
    assertThat(builder.isDefinedAt(new SparkListenerJobEnd(1, 1L, JobSucceeded$.MODULE$))).isTrue();
    assertThat(builder.isDefinedAt(new SparkListenerJobStart(1, 1L, Seq$.MODULE$.empty(), new Properties()))).isFalse();
}
Also used : SparkListenerSQLExecutionStart(org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionStart) SparkListenerSQLExecutionEnd(org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd) SparkListenerJobEnd(org.apache.spark.scheduler.SparkListenerJobEnd) SparkListenerJobStart(org.apache.spark.scheduler.SparkListenerJobStart) OpenLineage(io.openlineage.client.OpenLineage) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 3 with SparkListenerSQLExecutionEnd

use of org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd 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 4 with SparkListenerSQLExecutionEnd

use of org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd 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 5 with SparkListenerSQLExecutionEnd

use of org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd in project OpenLineage by OpenLineage.

the class OutputStatisticsOutputDatasetFacetBuilderTest method testIsDefined.

@Test
public void testIsDefined() {
    OutputStatisticsOutputDatasetFacetBuilder builder = new OutputStatisticsOutputDatasetFacetBuilder(OpenLineageContext.builder().openLineage(new OpenLineage(OpenLineageClient.OPEN_LINEAGE_CLIENT_URI)).sparkContext(sparkContext).build());
    assertThat(builder.isDefinedAt(new SparkListenerJobEnd(1, 1L, JobSucceeded$.MODULE$))).isTrue();
    assertThat(builder.isDefinedAt(new SparkListenerSQLExecutionEnd(1L, 1L))).isFalse();
}
Also used : SparkListenerSQLExecutionEnd(org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd) SparkListenerJobEnd(org.apache.spark.scheduler.SparkListenerJobEnd) OpenLineage(io.openlineage.client.OpenLineage) Test(org.junit.jupiter.api.Test)

Aggregations

OpenLineage (io.openlineage.client.OpenLineage)6 SparkListenerSQLExecutionEnd (org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd)6 Test (org.junit.jupiter.api.Test)6 SparkListenerJobEnd (org.apache.spark.scheduler.SparkListenerJobEnd)4 Properties (java.util.Properties)3 SparkListenerJobStart (org.apache.spark.scheduler.SparkListenerJobStart)3 SparkListenerSQLExecutionStart (org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionStart)3 RunFacet (io.openlineage.client.OpenLineage.RunFacet)2 HashMap (java.util.HashMap)2 SparkListenerStageCompleted (org.apache.spark.scheduler.SparkListenerStageCompleted)1 SparkListenerStageSubmitted (org.apache.spark.scheduler.SparkListenerStageSubmitted)1