You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "gustavodemorais (via GitHub)" <gi...@apache.org> on 2025/06/19 12:12:25 UTC
[PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
gustavodemorais opened a new pull request, #26703:
URL: https://github.com/apache/flink/pull/26703
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
We now support time attributes for the Multi Joins by materializing them.
## Brief change log
- Add visitMultiJoin to RelTimeIndicatorConverter
- Adjust rules to allow time attributes for multijoin
- Add mapped missing tests
- Add multijoin materialization tests
## Verifying this change
- Added rel plan test
- Added semantic test
- Added restore test
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (not applicable)
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2158169176
##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/RelTimeIndicatorConverterTest.xml:
##########
@@ -150,6 +150,44 @@ Sink(table=[default_catalog.default_database.appendSink1], fields=[long, sum])
Sink(table=[default_catalog.default_database.appendSink2], fields=[long, sum])
+- Reused(reference_id=[1])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT T1.rowtime, T2.proctime, T1.long, T2.`int`, T3.long
+FROM MyTable1 T1
+JOIN MyTable2 T2 ON T1.long = T2.long AND T1.`int` > 10
+JOIN MyTable1 T3 ON T1.long = T3.long AND T3.`int` < 20
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], proctime=[$5], long=[$1], int=[$4], long0=[$7])
++- LogicalJoin(condition=[AND(=($1, $7), <($8, 20))], joinType=[inner])
+ :- LogicalJoin(condition=[AND(=($1, $3), >($2, 10))], joinType=[inner])
+ : :- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+]]>
+ </Resource>
+ <Resource name="optimized exec plan">
+ <![CDATA[
+Calc(select=[rowtime, proctime, long, int0 AS int, long0])
++- Join(joinType=[InnerJoin], where=[(long = long0)], select=[rowtime, long, int0, proctime, long0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
Review Comment:
Where is the MultiJoin in this test? It seems you are testing only binary joins?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2157249121
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/RelTimeIndicatorConverter.java:
##########
@@ -521,6 +520,57 @@ private RelNode visitWindowTableAggregate(FlinkLogicalWindowTableAggregate table
tableAgg.getNamedProperties());
}
+ private RelNode visitMultiJoin(FlinkLogicalMultiJoin multiJoin) {
+ // visit and materialize children
+ final List<RelNode> newInputs =
+ multiJoin.getInputs().stream()
+ .map(input -> input.accept(this))
+ .map(this::materializeTimeIndicators)
+ .collect(Collectors.toList());
+
+ final List<RelDataTypeField> allFields =
+ newInputs.stream()
+ .flatMap(input -> input.getRowType().getFieldList().stream())
+ .collect(Collectors.toList());
+
+ final RexShuttle shuttle =
+ new RexShuttle() {
+ @Override
+ public RexNode visitInputRef(RexInputRef inputRef) {
+ if (isTimeIndicatorType(inputRef.getType())) {
+ return RexInputRef.of(inputRef.getIndex(), allFields);
+ } else {
+ return super.visitInputRef(inputRef);
+ }
+ }
+ };
+
+ final RexNode newJoinFilter = multiJoin.getJoinFilter().accept(shuttle);
Review Comment:
I'm missing a call to `RexTimeIndicatorMaterializer` here.
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/RelTimeIndicatorConverter.java:
##########
@@ -521,6 +520,57 @@ private RelNode visitWindowTableAggregate(FlinkLogicalWindowTableAggregate table
tableAgg.getNamedProperties());
}
+ private RelNode visitMultiJoin(FlinkLogicalMultiJoin multiJoin) {
+ // visit and materialize children
+ final List<RelNode> newInputs =
+ multiJoin.getInputs().stream()
+ .map(input -> input.accept(this))
+ .map(this::materializeTimeIndicators)
+ .collect(Collectors.toList());
+
+ final List<RelDataTypeField> allFields =
+ newInputs.stream()
+ .flatMap(input -> input.getRowType().getFieldList().stream())
+ .collect(Collectors.toList());
+
+ final RexShuttle shuttle =
+ new RexShuttle() {
Review Comment:
make this a static inner class and share it with `visitJoin`
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2158210747
##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/RelTimeIndicatorConverterTest.xml:
##########
@@ -150,6 +150,44 @@ Sink(table=[default_catalog.default_database.appendSink1], fields=[long, sum])
Sink(table=[default_catalog.default_database.appendSink2], fields=[long, sum])
+- Reused(reference_id=[1])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT T1.rowtime, T2.proctime, T1.long, T2.`int`, T3.long
+FROM MyTable1 T1
+JOIN MyTable2 T2 ON T1.long = T2.long AND T1.`int` > 10
+JOIN MyTable1 T3 ON T1.long = T3.long AND T3.`int` < 20
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], proctime=[$5], long=[$1], int=[$4], long0=[$7])
++- LogicalJoin(condition=[AND(=($1, $7), <($8, 20))], joinType=[inner])
+ :- LogicalJoin(condition=[AND(=($1, $3), >($2, 10))], joinType=[inner])
+ : :- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+]]>
+ </Resource>
+ <Resource name="optimized exec plan">
+ <![CDATA[
+Calc(select=[rowtime, proctime, long, int0 AS int, long0])
++- Join(joinType=[InnerJoin], where=[(long = long0)], select=[rowtime, long, int0, proctime, long0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
Review Comment:
It's the testThreeWayJoinWithTimeAttributesMaterialization inside MultiJoinTest.
Two minor reasons I put it here and not there:
- The whole file is still in scala instead of java
- I wasn't sure if it's safe the modify the tableConfig for only one test (if the tests even run in parallel). TestJoin would require the MultiJoinEnabled config to be false the the MJ for it to be true.
Let me know if that makes sense or else I can move the test here.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr merged PR #26703:
URL: https://github.com/apache/flink/pull/26703
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2158210747
##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/RelTimeIndicatorConverterTest.xml:
##########
@@ -150,6 +150,44 @@ Sink(table=[default_catalog.default_database.appendSink1], fields=[long, sum])
Sink(table=[default_catalog.default_database.appendSink2], fields=[long, sum])
+- Reused(reference_id=[1])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT T1.rowtime, T2.proctime, T1.long, T2.`int`, T3.long
+FROM MyTable1 T1
+JOIN MyTable2 T2 ON T1.long = T2.long AND T1.`int` > 10
+JOIN MyTable1 T3 ON T1.long = T3.long AND T3.`int` < 20
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], proctime=[$5], long=[$1], int=[$4], long0=[$7])
++- LogicalJoin(condition=[AND(=($1, $7), <($8, 20))], joinType=[inner])
+ :- LogicalJoin(condition=[AND(=($1, $3), >($2, 10))], joinType=[inner])
+ : :- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+]]>
+ </Resource>
+ <Resource name="optimized exec plan">
+ <![CDATA[
+Calc(select=[rowtime, proctime, long, int0 AS int, long0])
++- Join(joinType=[InnerJoin], where=[(long = long0)], select=[rowtime, long, int0, proctime, long0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
Review Comment:
It's the testThreeWayJoinWithTimeAttributesMaterialization inside MultiJoinTest.
Two minor reasons I put it here and not there:
- The whole file is still in scala instead of java
- I wasn't sure if it's safe the modify the tableConfig for only one test. TestJoin would require the MultiJoinEnabled config to be false the the MJ for it to be true.
Let me know if that makes sense or else I can move the test here.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2157315749
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/RelTimeIndicatorConverter.java:
##########
@@ -521,6 +520,57 @@ private RelNode visitWindowTableAggregate(FlinkLogicalWindowTableAggregate table
tableAgg.getNamedProperties());
}
+ private RelNode visitMultiJoin(FlinkLogicalMultiJoin multiJoin) {
+ // visit and materialize children
+ final List<RelNode> newInputs =
+ multiJoin.getInputs().stream()
+ .map(input -> input.accept(this))
+ .map(this::materializeTimeIndicators)
+ .collect(Collectors.toList());
+
+ final List<RelDataTypeField> allFields =
+ newInputs.stream()
+ .flatMap(input -> input.getRowType().getFieldList().stream())
+ .collect(Collectors.toList());
+
+ final RexShuttle shuttle =
+ new RexShuttle() {
Review Comment:
actually, I think this shuttle is not required. RexTimeIndicatorMaterializer should be able to do the job, no?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #26703:
URL: https://github.com/apache/flink/pull/26703#issuecomment-2987892392
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "209afc20ce7063970628867171d517b1ecdb1859",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "209afc20ce7063970628867171d517b1ecdb1859",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 209afc20ce7063970628867171d517b1ecdb1859 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2157538129
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/RelTimeIndicatorConverter.java:
##########
@@ -521,6 +520,57 @@ private RelNode visitWindowTableAggregate(FlinkLogicalWindowTableAggregate table
tableAgg.getNamedProperties());
}
+ private RelNode visitMultiJoin(FlinkLogicalMultiJoin multiJoin) {
+ // visit and materialize children
+ final List<RelNode> newInputs =
+ multiJoin.getInputs().stream()
+ .map(input -> input.accept(this))
+ .map(this::materializeTimeIndicators)
+ .collect(Collectors.toList());
+
+ final List<RelDataTypeField> allFields =
+ newInputs.stream()
+ .flatMap(input -> input.getRowType().getFieldList().stream())
+ .collect(Collectors.toList());
+
+ final RexShuttle shuttle =
+ new RexShuttle() {
Review Comment:
Thanks for the observation. Replaced the custom shuttle with RexTimeIndicatorMaterializer and things look good: https://github.com/apache/flink/pull/26703/commits/70edb6e7616dea8266d49fe520bd52938917369c
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2158252923
##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/RelTimeIndicatorConverterTest.xml:
##########
@@ -150,6 +150,44 @@ Sink(table=[default_catalog.default_database.appendSink1], fields=[long, sum])
Sink(table=[default_catalog.default_database.appendSink2], fields=[long, sum])
+- Reused(reference_id=[1])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT T1.rowtime, T2.proctime, T1.long, T2.`int`, T3.long
+FROM MyTable1 T1
+JOIN MyTable2 T2 ON T1.long = T2.long AND T1.`int` > 10
+JOIN MyTable1 T3 ON T1.long = T3.long AND T3.`int` < 20
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], proctime=[$5], long=[$1], int=[$4], long0=[$7])
++- LogicalJoin(condition=[AND(=($1, $7), <($8, 20))], joinType=[inner])
+ :- LogicalJoin(condition=[AND(=($1, $3), >($2, 10))], joinType=[inner])
+ : :- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable1]])
+]]>
+ </Resource>
+ <Resource name="optimized exec plan">
+ <![CDATA[
+Calc(select=[rowtime, proctime, long, int0 AS int, long0])
++- Join(joinType=[InnerJoin], where=[(long = long0)], select=[rowtime, long, int0, proctime, long0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
Review Comment:
Thanks for the explanation. This is enough context for me.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37962][table] Add visitMultiJoin to RelTimeIndicatorConverter [flink]
Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #26703:
URL: https://github.com/apache/flink/pull/26703#discussion_r2157538489
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/RelTimeIndicatorConverter.java:
##########
@@ -521,6 +520,57 @@ private RelNode visitWindowTableAggregate(FlinkLogicalWindowTableAggregate table
tableAgg.getNamedProperties());
}
+ private RelNode visitMultiJoin(FlinkLogicalMultiJoin multiJoin) {
+ // visit and materialize children
+ final List<RelNode> newInputs =
+ multiJoin.getInputs().stream()
+ .map(input -> input.accept(this))
+ .map(this::materializeTimeIndicators)
+ .collect(Collectors.toList());
+
+ final List<RelDataTypeField> allFields =
+ newInputs.stream()
+ .flatMap(input -> input.getRowType().getFieldList().stream())
+ .collect(Collectors.toList());
+
+ final RexShuttle shuttle =
+ new RexShuttle() {
+ @Override
+ public RexNode visitInputRef(RexInputRef inputRef) {
+ if (isTimeIndicatorType(inputRef.getType())) {
+ return RexInputRef.of(inputRef.getIndex(), allFields);
+ } else {
+ return super.visitInputRef(inputRef);
+ }
+ }
+ };
+
+ final RexNode newJoinFilter = multiJoin.getJoinFilter().accept(shuttle);
Review Comment:
Same as above https://github.com/apache/flink/pull/26703/commits/70edb6e7616dea8266d49fe520bd52938917369c
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org