MartijnVisser commented on code in PR #27727:
URL: https://github.com/apache/flink/pull/27727#discussion_r4633663450
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/common/CommonExecTableSourceScan.java:
##########
@@ -218,6 +219,18 @@ protected Transformation<RowData> translateToPlanInternal(
if (sourceTransform instanceof TransformationWithLineage) {
((TransformationWithLineage<RowData>) sourceTransform)
.setLineageVertex(sourceLineageVertex);
+ } else {
+ // When DataStreamScanProvider returns a multi-operator pipeline,
the outermost
+ // transformation may not implement TransformationWithLineage.
Search the transitive
+ // predecessors to find a SourceTransformation or
LegacySourceTransformation that does.
+ for (Transformation<?> predecessor :
sourceTransform.getTransitivePredecessors()) {
+ if (predecessor != sourceTransform
+ && predecessor instanceof TransformationWithLineage) {
+ ((TransformationWithLineage<?>) predecessor)
+ .setLineageVertex(sourceLineageVertex);
+ break;
Review Comment:
With a union only the first source gets the table vertex. Might make sense
to require exactly one source.
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/common/CommonExecTableSourceScan.java:
##########
@@ -183,6 +183,7 @@ protected Transformation<RowData> translateToPlanInternal(
.getTransformation();
metadata.fill(sourceTransform);
} else if (provider instanceof DataStreamScanProvider) {
+ lineageVertex = TableLineageUtils.extractLineageDataset(provider);
Review Comment:
Providers that aren't a LineageVertexProvider themselves, like Kafka's,
still lose the connector's namespace. Falling back to the vertex already on the
source would fix that. Here or in a follow-up?
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/TransformationsTest.java:
##########
@@ -254,6 +263,299 @@ void testMultiTransformSourcesV1() throws IOException {
"\\[\\d+\\]\\:TableSourceScan\\(table=\\[\\[default_catalog, default_database,
T\\]\\], fields=\\[i\\]\\)"));
}
+ @Test
+ void testDataStreamScanProviderLineage() {
+ final StreamTableEnvironment env =
+ StreamTableEnvironment.create(
+ StreamExecutionEnvironment.getExecutionEnvironment(),
+
EnvironmentSettings.newInstance().inStreamingMode().build());
+
+ final DataStreamScanProvider scanProvider =
+ new DataStreamScanProvider() {
+ @Override
+ public boolean isBounded() {
+ return false;
+ }
+
+ @Override
+ public DataStream<RowData> produceDataStream(
+ ProviderContext providerContext,
StreamExecutionEnvironment execEnv) {
+ // Single-operator pipeline: returns the
SourceTransformation directly
Review Comment:
The `map` makes this a multi-operator pipeline as well, so a provider that
returns the source directly isn't covered.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/lineage/TableLineageUtilsTest.java:
##########
@@ -114,4 +125,124 @@ void testCreateTableLineageDatasetWithoutCatalog() {
assertThat(tableLineageDataset.catalogContext().getCatalogName()).isEmpty();
assertThat(tableLineageDataset.name()).isEqualTo(objectIdentifier.asSummaryString());
}
+
+ @Test
+ void testExtractLineageDatasetFromDataStreamScanProvider() {
Review Comment:
These four also pass on master, since `extractLineageDataset` didn't change,
so they can go.
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/common/CommonExecTableSourceScan.java:
##########
@@ -218,6 +219,18 @@ protected Transformation<RowData> translateToPlanInternal(
if (sourceTransform instanceof TransformationWithLineage) {
((TransformationWithLineage<RowData>) sourceTransform)
.setLineageVertex(sourceLineageVertex);
+ } else {
Review Comment:
This also runs for `TransformationScanProvider`, so `fromDataStream` over a
source with its own lineage now reports an anonymous table with an empty
namespace instead of the connector's dataset. I think this should only run for
`DataStreamScanProvider`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]