jingzi created FLINK-41776:
------------------------------
Summary: Support lookup-side table lineage in SQL lookup joins
Key: FLINK-41776
URL: https://issues.apache.org/jira/browse/FLINK-41776
Project: Flink
Issue Type: Improvement
Components: Table SQL / Planner
Environment: Verified baseline: Apache Flink upstream master
75a3d070198c9bd2957a953f54f257aa8387b2c5 (2.5-SNAPSHOT). Homebrew OpenJDK
17.0.15, macOS aarch64, Maven wrapper 3.9.16. Planner-only reproduction, no
submitted job or external backend.
Reporter: jingzi
h3. Problem
SQL processing-time lookup joins read a fact table and a lookup table, but the
planner-generated LineageGraph omits the lookup-side table on the verified
upstream baseline. Consumers of JobCreatedEvent.lineageGraph() therefore miss
this dependency.
h3. Reproduction
Reproduced on upstream master commit 75a3d070198c9bd2957a953f54f257aa8387b2c5
(2.5-SNAPSHOT), using JDK 17.0.15 and Maven wrapper 3.9.16. Released versions
have not been tested.
Use the existing values connector in flink-table-planner tests; it is a test
fixture, not a connector shipped with the SQL Client.
{code:sql}
CREATE TABLE FactTable (id INT, pt AS PROCTIME())
WITH ('connector' = 'values', 'bounded' = 'false');
CREATE TABLE LookupDimension (id INT, label STRING)
WITH ('connector' = 'values', 'bounded' = 'true', 'disable-lookup' = 'false',
'async' = 'false');
CREATE TABLE ResultTable (id INT, label STRING)
WITH ('connector' = 'values', 'sink-insert-only' = 'true');
INSERT INTO ResultTable
SELECT f.id, d.label FROM FactTable f
LEFT JOIN LookupDimension FOR SYSTEM_TIME AS OF f.pt d ON f.id = d.id;
{code}
Generate transformations using TableTestUtil.generateTransformations, construct
a StreamGraph with StreamGraphGenerator, and inspect getLineageGraph(). Do not
execute the INSERT. No external database, broker or OpenLineage dependency is
needed.
Actual inputs: FactTable. Actual edge: FactTable -> ResultTable.
Expected inputs: FactTable and LookupDimension. Expected edges: FactTable ->
ResultTable and LookupDimension -> ResultTable.
The same omission was observed for sync LEFT, sync INNER and async LEFT lookup
joins. The unmodified-baseline reproducer has 4 tests: 3 assertion failures for
the missing dimension and 1 passing scan-only control, with no execution errors
or skips.
h3. Proposed direction
Represent the resolved lookup table as a metadata-only dependency and connect
it only to downstream sinks reachable from that lookup transformation. Do not
introduce a physical source or recreate/execute lookup providers or functions
solely to collect lineage. Cover sync, ordinary async, key-ordered async and
materialized lookup paths, preserving physical inputs, operator identity,
execution mode, state/changelog semantics and existing validation errors.
A local prototype passes a 53-module clean build and 184 selected JUnit cases
with no failures, errors or skips. The unchanged reproducer turns green. Tests
cover exact graph edges, branch isolation, old/new compiled plans, boundedness,
cache/retry behavior and local state restoration. This is local prototype
validation, not a claim that full-project CI/E2E, production or Kafka transport
has been verified. The internal API and conservative treatment of unknown
lookup boundedness remain open for review.
h3. Related work
FLIP-314 explicitly lists lookup source lineage as future work:
https://cwiki.apache.org/confluence/spaces/FLINK/pages/255070913/FLIP-314+Support+Customized+Job+Lineage+Listener
FLINK-39219 concerns DataStream scan/sink provider extraction; FLINK-41051
concerns JDBC dataset naming. This proposal concerns the native lookup
dependency in the planner-generated graph.
I would like to contribute this improvement. Could a committer review the scope
and approach and assign the ticket if appropriate? I will follow the community
discussion before opening a PR.
AI-assisted preparation: OpenAI Codex (GPT-6); the proposal and prototype have
been reviewed and tested locally.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)