-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the DataSourceV2ScanRelationInputDatasetBuilder into two classe…
…s, focused on different Spark lifecycle events These are: 1. DataSourceV2ScanRelationOnEndInputDatasetBuilder 2. DataSourceV2ScanRelationOnStartInputDatasetBuilder Also refactored the tests Signed-off-by: Damien Hawes <[email protected]>
- Loading branch information
Showing
15 changed files
with
306 additions
and
126 deletions.
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
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
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
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
57 changes: 57 additions & 0 deletions
57
...lineage/spark3/agent/lifecycle/plan/DataSourceV2ScanRelationOnEndInputDatasetBuilder.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,57 @@ | ||
/* | ||
/* Copyright 2018-2024 contributors to the OpenLineage project | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.openlineage.spark3.agent.lifecycle.plan; | ||
|
||
import io.openlineage.client.OpenLineage; | ||
import io.openlineage.client.OpenLineage.InputDataset; | ||
import io.openlineage.spark.api.AbstractQueryPlanInputDatasetBuilder; | ||
import io.openlineage.spark.api.DatasetFactory; | ||
import io.openlineage.spark.api.OpenLineageContext; | ||
import io.openlineage.spark3.agent.utils.DataSourceV2RelationDatasetExtractor; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.spark.scheduler.SparkListenerEvent; | ||
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan; | ||
import org.apache.spark.sql.execution.datasources.v2.DataSourceV2Relation; | ||
import org.apache.spark.sql.execution.datasources.v2.DataSourceV2ScanRelation; | ||
import org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionEnd; | ||
|
||
@Slf4j | ||
public final class DataSourceV2ScanRelationOnEndInputDatasetBuilder | ||
extends AbstractQueryPlanInputDatasetBuilder<DataSourceV2ScanRelation> { | ||
private final DatasetFactory<InputDataset> factory; | ||
|
||
public DataSourceV2ScanRelationOnEndInputDatasetBuilder( | ||
OpenLineageContext context, DatasetFactory<InputDataset> factory) { | ||
super(context, true); | ||
this.factory = Objects.requireNonNull(factory, "parameter: factory"); | ||
} | ||
|
||
@Override | ||
public boolean isDefinedAt(SparkListenerEvent event) { | ||
return event instanceof SparkListenerSQLExecutionEnd; | ||
} | ||
|
||
@Override | ||
protected boolean isDefinedAtLogicalPlan(LogicalPlan plan) { | ||
return plan instanceof DataSourceV2ScanRelation; | ||
} | ||
|
||
@Override | ||
public List<InputDataset> apply(DataSourceV2ScanRelation plan) { | ||
DataSourceV2Relation relation = plan.relation(); | ||
OpenLineage.DatasetFacetsBuilder datasetFacetsBuilder = | ||
context.getOpenLineage().newDatasetFacetsBuilder(); | ||
return DataSourceV2RelationDatasetExtractor.extract( | ||
factory, context, relation, datasetFacetsBuilder); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.getClass().getSimpleName(); | ||
} | ||
} |
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
Oops, something went wrong.