You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "jeyhunkarimov (via GitHub)" <gi...@apache.org> on 2024/01/31 12:34:44 UTC
Re: [PR] [FLINK-33396][table-planner] clear table alias in subquery [flink]
jeyhunkarimov commented on code in PR #24239:
URL: https://github.com/apache/flink/pull/24239#discussion_r1472756844
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/optimize/ClearQueryBlockAliasResolver.java:
##########
@@ -31,22 +31,19 @@
import java.util.stream.Collectors;
/** A shuttle to remove query block alias hint. */
-public class ClearQueryBlockAliasResolver extends RelShuttleImpl {
+public class ClearQueryBlockAliasResolver extends RelHomogeneousShuttle {
public List<RelNode> resolve(List<RelNode> roots) {
return roots.stream().map(node -> node.accept(this)).collect(Collectors.toList());
}
@Override
- protected RelNode visitChild(RelNode parent, int i, RelNode child) {
- RelNode newParent = clearQueryBlockAlias(parent);
- return super.visitChild(newParent, i, child);
- }
-
- @Override
- public RelNode visit(TableScan scan) {
- RelNode newScan = clearQueryBlockAlias(scan);
- return super.visit(newScan);
+ public RelNode visit(RelNode other) {
+ if (FlinkRelOptUtil.containsSubQuery(other)) {
+ other = FlinkHints.resolveSubQuery(other, relNode -> relNode.accept(this));
Review Comment:
I would avoid mutating input parameter here
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/optimize/ClearQueryBlockAliasResolver.java:
##########
@@ -31,22 +31,19 @@
import java.util.stream.Collectors;
/** A shuttle to remove query block alias hint. */
-public class ClearQueryBlockAliasResolver extends RelShuttleImpl {
+public class ClearQueryBlockAliasResolver extends RelHomogeneousShuttle {
public List<RelNode> resolve(List<RelNode> roots) {
return roots.stream().map(node -> node.accept(this)).collect(Collectors.toList());
}
@Override
- protected RelNode visitChild(RelNode parent, int i, RelNode child) {
- RelNode newParent = clearQueryBlockAlias(parent);
- return super.visitChild(newParent, i, child);
- }
-
- @Override
- public RelNode visit(TableScan scan) {
- RelNode newScan = clearQueryBlockAlias(scan);
- return super.visit(newScan);
+ public RelNode visit(RelNode other) {
+ if (FlinkRelOptUtil.containsSubQuery(other)) {
+ other = FlinkHints.resolveSubQuery(other, relNode -> relNode.accept(this));
+ }
+ RelNode result = clearQueryBlockAlias(other);
Review Comment:
Why the issue cannot be fixed by adjusting the `clearQueryBlockAlias` method?
##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/hints/batch/NestLoopJoinHintTest.xml:
##########
@@ -679,8 +680,8 @@ HashJoin(joinType=[LeftSemiJoin], where=[=(a1, a2)], select=[a1, b1], build=[rig
+- Calc(select=[a2])
+- NestedLoopJoin(joinType=[InnerJoin], where=[=(a2, a3)], select=[a2, a3], build=[left])
:- Exchange(distribution=[broadcast])
- : +- TableSourceScan(table=[[default_catalog, default_database, T2, project=[a2], metadata=[]]], fields=[a2], hints=[[[ALIAS options:[T2]]]])
- +- TableSourceScan(table=[[default_catalog, default_database, T3, project=[a3], metadata=[]]], fields=[a3], hints=[[[ALIAS options:[T3]]]])
Review Comment:
Can we add test[s] to `ClearQueryBlockAliasResolverTest` with other hints than query block alias, to make sure that these hints are not removed
--
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