[FLINK-40158][table-planner] Support LATERAL SNAPSHOT join in batch mode#28763
Conversation
In batch, all input is bounded and append-only, so the processing-time LATERAL SNAPSHOT join degenerates to a regular join of the probe side against the (final) build side; the SNAPSHOT-specific arguments are dropped. BatchPhysicalLateralSnapshotJoinRule converts the logical snapshot join into a shuffle hash join that builds the (smaller) SNAPSHOT side, mirroring StreamPhysicalLateralSnapshotJoinRule. Generated-By: Claude Opus 4.8 (1M context)
| if (rowtimeCount > 1) { | ||
| throw new ValidationException( | ||
| String.format( | ||
| "The build-side input of a LATERAL SNAPSHOT join must not have more than one " | ||
| + "row-time attribute, but found %d.", | ||
| rowtimeCount)); |
There was a problem hiding this comment.
Can we get rid of this check? Having more than one time attribute should be fine, as long as watermarks are flowing? We should follow the principle of as little errors as possible.
There was a problem hiding this comment.
The LateralSnapshotJoinOperator orders build-side records based on their event-time attribute. If there would be more than one, this behavior could be ambiguous.
We could also ask for a timestamp column in the SNAPSHOT function, but that would make it harder to use IMO.
|
|
||
| /** | ||
| * Converts a {@link FlinkLogicalLateralSnapshotJoin} (created by {@link | ||
| * org.apache.flink.table.planner.plan.rules.logical.LogicalJoinToLateralSnapshotJoinRule}) into a |
There was a problem hiding this comment.
nit: please use fully qualified imports, very annoying for readability otherwise
| * org.apache.flink.table.planner.plan.rules.logical.LogicalJoinToLateralSnapshotJoinRule}) into a | ||
| * regular batch {@link BatchPhysicalHashJoin} for batch execution. | ||
| * | ||
| * <p>In batch all input is bounded and append-only (batch rejects non-insert-only sources up |
There was a problem hiding this comment.
| * <p>In batch all input is bounded and append-only (batch rejects non-insert-only sources up | |
| * <p>In batch all input is bounded and append-only (batch rejects or in the future materializes non-insert-only sources up |
| * | ||
| * <p>In batch all input is bounded and append-only, so the processing-time {@code LATERAL SNAPSHOT} | ||
| * join degenerates to a regular join of the probe side against the (final) build side. {@link | ||
| * org.apache.flink.table.planner.plan.rules.physical.batch.BatchPhysicalLateralSnapshotJoinRule} |
There was a problem hiding this comment.
nit:
| * org.apache.flink.table.planner.plan.rules.physical.batch.BatchPhysicalLateralSnapshotJoinRule} | |
| * BatchPhysicalLateralSnapshotJoinRule} |
| } | ||
|
|
||
| @Test | ||
| void testInnerJoinWithCteBuildSide() { |
There was a problem hiding this comment.
remove? we can assume CTEs work?
| } | ||
|
|
||
| @Test | ||
| void testSnapshotArgumentsAreDropped() { |
| } | ||
|
|
||
| @Test | ||
| void testDefaultCompileTime() { |
There was a problem hiding this comment.
same as inner join, remove?
| } | ||
|
|
||
| @Test | ||
| void testRejectInvalidSnapshotArgument() { |
There was a problem hiding this comment.
remove? let's avoid duplicate tests. this test should be about the specifics of batch mode.
| * in batch mode a {@code LATERAL SNAPSHOT} join is executed as a regular join of the probe side | ||
| * against the (final) build side. | ||
| */ | ||
| class LateralSnapshotJoinITCase { |
There was a problem hiding this comment.
Can we use the SemanticTestsBase for this?
What is the purpose of the change
Brief change log
Verifying this change
PR includes unit tests and ITCases
Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code 2.1.200 (Opus 4.8)