You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/12/21 13:29:10 UTC

[GitHub] [flink] Mulavar opened a new pull request, #21545: [FLINK-30396][table]make alias hint take effect in correlate

Mulavar opened a new pull request, #21545:
URL: https://github.com/apache/flink/pull/21545

   <!--
   *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
   make alias hint take effect in correlate
   *(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
   
   
   ## Brief change log
   
   *(for example:)*
     - *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
     - *Deployments RPC transmits only the blob storage reference*
     - *TaskManagers retrieve the TaskInfo from the blob cache*
   
   
   ## Verifying this change
   
   Please make sure both new and modified tests in this PR follows the conventions defined in our code quality guide: https://flink.apache.org/contributing/code-style-and-quality-common.html#testing
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (100MB)*
     - *Extended integration test for recovery after master (JobManager) failure*
     - *Added test that validates that TaskInfo is transferred only once across recoveries*
     - *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   


-- 
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


[GitHub] [flink] godfreyhe commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
godfreyhe commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1057055251


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHints.java:
##########
@@ -189,18 +191,33 @@ public static RelNode capitalizeJoinHints(RelNode root) {
 
     private static class CapitalizeJoinHintShuttle extends RelShuttleImpl {
 
+        @Override
+        public RelNode visit(LogicalCorrelate correlate) {
+            return visitBiRel(correlate);
+        }
+
         @Override
         public RelNode visit(LogicalJoin join) {
-            List<RelHint> hints = join.getHints();
+            return visitBiRel(join);
+        }
+
+        private RelNode visitBiRel(BiRel biRel) {
+            Hintable hBiRel = (Hintable) biRel;
             AtomicBoolean changed = new AtomicBoolean(false);
             List<RelHint> hintsWithCapitalJoinHints =
-                    hints.stream()
+                    hBiRel.getHints().stream()
                             .map(
                                     hint -> {
                                         String capitalHintName =
                                                 hint.hintName.toUpperCase(Locale.ROOT);
                                         if (JoinStrategy.isJoinStrategy(capitalHintName)) {
                                             changed.set(true);
+                                            if (JoinStrategy.isLookupHint(hint.hintName)) {

Review Comment:
   can you add some tests to verify this change



-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1118018561


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/batch/table/JoinTest.scala:
##########
@@ -204,6 +205,29 @@ class JoinTest extends TableTestBase {
     val joinT = ds1.join(ds2, 'b === 'e && Merger('a, 'd) === 10)
     util.verifyExecPlan(joinT)
   }
+
+  @Test
+  def testJoinInvalidUDTFWithLookupJoinHint(): Unit = {

Review Comment:
   will move this to stream's JoinTest



-- 
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


[GitHub] [flink] flinkbot commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1361317441

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "8f18fe7d619a2aec0f48818126bb2617ef185999",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "8f18fe7d619a2aec0f48818126bb2617ef185999",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 8f18fe7d619a2aec0f48818126bb2617ef185999 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


[GitHub] [flink] Mulavar commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1055601467


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHintStrategies.java:
##########
@@ -62,8 +62,10 @@ public static HintStrategyTable createHintStrategyTable() {
                 // internal join hint used for alias
                 .hintStrategy(
                         FlinkHints.HINT_ALIAS,
-                        // currently, only join hints care about query block alias
-                        HintStrategy.builder(HintPredicates.JOIN)
+                        // currently, only correlate&join hints care about query block alias
+                        HintStrategy.builder(
+                                        HintPredicates.or(
+                                                HintPredicates.CORRELATE, HintPredicates.JOIN))
                                 .optionChecker(fixedSizeListOptionChecker(1))

Review Comment:
   sorry, I'm not quite understand what's wrong with this piece of code, could u give me more suggestions about it?



-- 
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


[GitHub] [flink] Mulavar commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1055592769


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHintStrategies.java:
##########
@@ -62,8 +62,10 @@ public static HintStrategyTable createHintStrategyTable() {
                 // internal join hint used for alias
                 .hintStrategy(
                         FlinkHints.HINT_ALIAS,
-                        // currently, only join hints care about query block alias
-                        HintStrategy.builder(HintPredicates.JOIN)
+                        // currently, only correlate&join hints care about query block alias
+                        HintStrategy.builder(
+                                        HintPredicates.or(
+                                                HintPredicates.CORRELATE, HintPredicates.JOIN))
                                 .optionChecker(fixedSizeListOptionChecker(1))

Review Comment:
   the fixedSizeListOptionChecker is used to validate alias hint, not lookup hint.



-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1370645255

   @godfreyhe @lincoln-lil Hi, is there any problem with this pr?


-- 
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


[GitHub] [flink] lincoln-lil commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1423545142

   @Mulavar there's some compilation error need to be fixed first, please take a look.


-- 
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


[GitHub] [flink] lincoln-lil commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1445551956

   @Mulavar I've created one https://github.com/apache/flink/pull/22025,  please help to check if you have time


-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1101591117


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/alias/ClearLookupJoinHintWithInvalidPropagationShuttleTest.java:
##########
@@ -167,8 +180,114 @@ public void testClearLookupHintWithInvalidPropagationToSubQuery() {
                                 JoinRelType.INNER,
                                 builder.equals(builder.field(2, 0, "a"), builder.field(2, 1, "a")))
                         .project(builder.field(1, 0, "a"))
-                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("lookup", true, true))
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("src", true, true))
+                        .build();
+        verifyRelPlan(root);
+    }
+
+    @Test
+    public void testNoNeedToClearLookupHintWhileJoinWithUnnest() {
+        //  SELECT /*+ LOOKUP('table'='d', 'retry-predicate'='lookup_miss',
+        //  'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        //  'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        //  */ s.a
+        //  FROM src s
+        //  CROSS JOIN UNNEST(s.ds) AS d(a)
+
+        System.out.println(util.tableEnv().explainSql(" SELECT /*+ LOOKUP('table'='d', "
+                + "'retry-predicate'='lookup_miss',\n"
+                + "         'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',\n"
+                + "         'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')\n"
+                + "         */ s.a\n"
+                + "              FROM src s\n"
+                + "              CROSS JOIN UNNEST(s.ds) AS d(a)"));
+        CorrelationId cid = builder.getCluster().createCorrel();
+        RelDataType dsType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory()
+                                                .createArrayType(
+                                                        builder
+                                                                .getTypeFactory()
+                                                                .createSqlType(SqlTypeName.BIGINT),
+                                                        -1L
+                                                )),
+                                Collections.singletonList("ds"));
+        RelOptCluster cluster = util.getPlanner().plannerContext().getCluster();
+        RelNode root =
+                builder.scan("src")
+                        .project(builder.field(1, 0, "a"))
+                        .push(LogicalValues.createOneRow(cluster))
+                        .project(builder.field(
+                                builder.getRexBuilder().makeCorrel(dsType, cid),
+                                "ds"))
+                        .uncollect(Collections.singletonList("a"), false)
+                        .project(builder.field(1, 0, "a"))
+                        .correlate(
+                                JoinRelType.INNER,
+                                cid)
+                        .project(builder.field(1, 0, "a"))
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("d", true, false))
+                        .build();
+        verifyRelPlan(root);
+    }
+
+    @Test
+    public void testNoNeedToClearLookupHintWhileJoinWithUDTF() {
+        //  SELECT /*+ LOOKUP('table'='d', 'retry-predicate'='lookup_miss',
+        //  'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        //  'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        //  */ s.a
+        //  FROM src s
+        //  CROSS JOIN LATERAL TABLE(MockOffset(a)) AS d(b)
+
+        CorrelationId cid = builder.getCluster().createCorrel();
+        RelDataType bType = builder.getTypeFactory().
+                createStructType(
+                        Collections.singletonList(
+                                builder
+                                        .getTypeFactory()
+                                        .createSqlType(
+                                                SqlTypeName.BIGINT)),
+                        Collections.singletonList(
+                                "b"));
+        RelNode root =
+                builder.scan("src")
+                        .project(builder.field(1, 0, "a"))
+                        .functionScan(
+                                new SqlCollectionTableOperator("TABLE", SqlModality.RELATION) {
+                                    @Override
+                                    public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
+                                        return bType;
+                                    }
+                                },
+                                0,
+                                builder
+                                        .getRexBuilder()
+                                        .makeFieldAccess(
+                                                builder
+                                                        .getRexBuilder()
+                                                        .makeCorrel(bType
+                                                                ,
+                                                                cid),
+                                                0))
+                        .correlate(
+                                JoinRelType.INNER,
+                                cid)
+                        .project(builder.field(1, 0, "a"))
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint(
+                                "d",
+                                true,
+                                false))
                         .build();
         verifyRelPlan(root);
     }
+
+    @FunctionHint(output = @DataTypeHint("ROW< b BIGINT >"))
+    public class MockOffsetTableFunction extends TableFunction<Long> {

Review Comment:
   nit: this can be a static class



-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1424001886

   @flinkbot run azure


-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1364478403

    @lincoln-lil Hi, the ci has finished successfully, please check the pr again when you're free


-- 
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


[GitHub] [flink] Mulavar commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1055585178


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/alias/ClearLookupCorrelateHintWithInvalidPropagationShuttleTest.java:
##########
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.alias;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.planner.functions.sql.FlinkSqlOperatorTable;
+import org.apache.flink.table.planner.hint.FlinkHints;
+import org.apache.flink.table.planner.plan.nodes.exec.spec.LookupJoinHintTestUtil;
+import org.apache.flink.table.planner.utils.TableTestUtil;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.CorrelationId;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.hint.RelHint;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/** Tests clearing lookup join hint with invalid propagation in stream. */
+public class ClearLookupCorrelateHintWithInvalidPropagationShuttleTest

Review Comment:
   yeah, I agree with that and I will overwrite the origin test with this.



-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1056946337


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/alias/ClearJoinHintWithInvalidPropagationShuttle.java:
##########
@@ -66,7 +78,7 @@ public RelNode visit(LogicalJoin join) {
 
         // there are no alias hints on this Join node

Review Comment:
   nit: Join -> Join / Correlate



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/alias/ClearJoinHintWithInvalidPropagationShuttle.java:
##########
@@ -49,14 +52,23 @@ public class ClearJoinHintWithInvalidPropagationShuttle extends RelShuttleImpl {
 
     @Override
     public RelNode visit(LogicalJoin join) {
-        List<RelHint> hints = join.getHints();
+        return visitBiRel(join);
+    }
+
+    @Override
+    public RelNode visit(LogicalCorrelate correlate) {
+        return visitBiRel(correlate);
+    }
+
+    private RelNode visitBiRel(BiRel biRel) {
+        List<RelHint> hints = ((Hintable) biRel).getHints();
 
         Set<String> allHintNames =
                 hints.stream().map(hint -> hint.hintName).collect(Collectors.toSet());
 
         // there are no join hints on this Join node

Review Comment:
   nit: Join -> Join / Correlate



-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1438817485

   @flinkbot run azure


-- 
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


[GitHub] [flink] Mulavar commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1101015734


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/alias/ClearLookupJoinHintWithInvalidPropagationShuttleTest.java:
##########
@@ -61,89 +76,208 @@ public void before() throws Exception {
                                 + ") WITH (\n"
                                 + " 'connector' = 'values'\n"
                                 + ")");
+        util.tableEnv()
+                .createTemporarySystemFunction(
+                        "MockOffset",
+                        new ClearLookupJoinHintWithInvalidPropagationShuttleTest()
+                        .new MockOffsetTableFunction());
     }
 
     @Test
     public void testNoNeedToClearLookupHint() {
         // SELECT /*+ LOOKUP('table'='lookup', 'retry-predicate'='lookup_miss',
-        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10') ) */ *
-        //  FROM src
-        //  JOIN lookup FOR SYSTEM_TIME AS OF T.proctime AS D
-        //      ON T.a = D.a
+        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        // */ s.a
+        // FROM src s
+        // JOIN lookup FOR SYSTEM_TIME AS OF s.pts AS d
+        // ON s.a=d.a
+        CorrelationId cid = builder.getCluster().createCorrel();
+        RelDataType aType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory().createSqlType(SqlTypeName.BIGINT)),
+                                Collections.singletonList("a"));
+        RelDataType ptsType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory()
+                                                .createProctimeIndicatorType(false)),
+                                Collections.singletonList("pts"));
         RelNode root =
                 builder.scan("src")
                         .scan("lookup")
                         .snapshot(builder.getRexBuilder().makeCall(FlinkSqlOperatorTable.PROCTIME))
-                        .join(
+                        .filter(
+                                builder.equals(
+                                        builder.field(
+                                                builder.getRexBuilder().makeCorrel(aType, cid),
+                                                "a"),
+                                        builder.getRexBuilder().makeInputRef(aType, 0)))
+                        .correlate(
                                 JoinRelType.INNER,
-                                builder.equals(builder.field(2, 0, "a"), builder.field(2, 1, "a")))
+                                cid,
+                                builder.getRexBuilder().makeInputRef(aType, 0),
+                                builder.getRexBuilder().makeInputRef(ptsType, 1))
                         .project(builder.field(1, 0, "a"))
-                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("lookup", false, true))
+                        .hints(RelHint.builder(FlinkHints.HINT_ALIAS).hintOption("t1").build())
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("d", true, false))
                         .build();
         verifyRelPlan(root);
     }
 
     @Test
-    public void testClearLookupHintWithInvalidPropagationToViewWhileViewHasLookupHints() {
-        // SELECT /*+ LOOKUP('table'='lookup', 'retry-predicate'='lookup_miss',
-        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10') ) */ *
-        //   FROM (
-        //     SELECT /*+ LOOKUP('table'='lookup', 'async'='true', 'output-mode'='allow_unordered',
-        // 'capacity'='1000', 'time-out'='300 s'
-        //       src.a, src.proctime
-        //     FROM src
-        //       JOIN lookup FOR SYSTEM_TIME AS OF T.proctime AS D
-        //         ON T.a = D.id
-        //     ) t1 JOIN lookup FOR SYSTEM_TIME AS OF t1.proctime AS t2 ON t1.a = t2.a
+    public void testClearLookupHintWithInvalidPropagationToSubQuery() {
+        // SELECT /*+ LOOKUP('table'='src', 'retry-predicate'='lookup_miss',
+        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        // */ t1.a
+        //  FROM (
+        //      SELECT s.a
+        //      FROM src s
+        //      JOIN lookup FOR SYSTEM_TIME AS OF s.pts AS d
+        //      ON s.a=d.a
+        //  ) t1
+        //  JOIN src t2
+        //  ON t1.a=t2.a
+
+        CorrelationId cid = builder.getCluster().createCorrel();
+        RelDataType aType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory().createSqlType(SqlTypeName.BIGINT)),
+                                Collections.singletonList("a"));
+        RelDataType ptsType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory()
+                                                .createProctimeIndicatorType(false)),
+                                Collections.singletonList("pts"));
         RelNode root =
                 builder.scan("src")
                         .scan("lookup")
                         .snapshot(builder.getRexBuilder().makeCall(FlinkSqlOperatorTable.PROCTIME))
-                        .join(
+                        .filter(
+                                builder.equals(
+                                        builder.field(
+                                                builder.getRexBuilder().makeCorrel(aType, cid),
+                                                "a"),
+                                        builder.getRexBuilder().makeInputRef(aType, 0)))
+                        .correlate(
                                 JoinRelType.INNER,
-                                builder.equals(builder.field(2, 0, "a"), builder.field(2, 1, "a")))
+                                cid,
+                                builder.getRexBuilder().makeInputRef(aType, 0),
+                                builder.getRexBuilder().makeInputRef(ptsType, 1))
                         .project(builder.field(1, 0, "a"))
-                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("lookup", false, true))
                         .hints(RelHint.builder(FlinkHints.HINT_ALIAS).hintOption("t1").build())
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("d", true, false))
                         .scan("src")
-                        .snapshot(builder.getRexBuilder().makeCall(FlinkSqlOperatorTable.PROCTIME))
+                        .hints(RelHint.builder(FlinkHints.HINT_ALIAS).hintOption("t2").build())
                         .join(
                                 JoinRelType.INNER,
                                 builder.equals(builder.field(2, 0, "a"), builder.field(2, 1, "a")))
                         .project(builder.field(1, 0, "a"))
-                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("lookup", true, false))
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("src", true, true))
                         .build();
         verifyRelPlan(root);
     }
 
     @Test
-    public void testClearLookupHintWithInvalidPropagationToSubQuery() {
-        // SELECT /*+ LOOKUP('table'='lookup', 'retry-predicate'='lookup_miss',
-        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
-        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s' */*
-        //   FROM (
-        //     SELECT src.a
-        //     FROM src
-        //     JOIN lookup FOR SYSTEM_TIME AS OF T.proctime AS D
-        //       ON T.a = D.id
-        //   ) t1 JOIN src t2 ON t1.a = t2.a
+    public void testNoNeedToClearLookupHintWhileJoinWithUnnest() {
+        //  SELECT /*+ LOOKUP('table'='d', 'retry-predicate'='lookup_miss',
+        //  'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        //  'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        //  */ s.a
+        //  FROM src s
+        //  CROSS JOIN UNNEST(s.ds) AS d(a)
+
+        System.out.println(

Review Comment:
   thanks.



-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1423682118

   @flinkbot run azure


-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1101012560


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/alias/ClearLookupJoinHintWithInvalidPropagationShuttleTest.java:
##########
@@ -61,89 +76,208 @@ public void before() throws Exception {
                                 + ") WITH (\n"
                                 + " 'connector' = 'values'\n"
                                 + ")");
+        util.tableEnv()
+                .createTemporarySystemFunction(
+                        "MockOffset",
+                        new ClearLookupJoinHintWithInvalidPropagationShuttleTest()
+                        .new MockOffsetTableFunction());
     }
 
     @Test
     public void testNoNeedToClearLookupHint() {
         // SELECT /*+ LOOKUP('table'='lookup', 'retry-predicate'='lookup_miss',
-        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10') ) */ *
-        //  FROM src
-        //  JOIN lookup FOR SYSTEM_TIME AS OF T.proctime AS D
-        //      ON T.a = D.a
+        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        // */ s.a
+        // FROM src s
+        // JOIN lookup FOR SYSTEM_TIME AS OF s.pts AS d
+        // ON s.a=d.a
+        CorrelationId cid = builder.getCluster().createCorrel();
+        RelDataType aType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory().createSqlType(SqlTypeName.BIGINT)),
+                                Collections.singletonList("a"));
+        RelDataType ptsType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory()
+                                                .createProctimeIndicatorType(false)),
+                                Collections.singletonList("pts"));
         RelNode root =
                 builder.scan("src")
                         .scan("lookup")
                         .snapshot(builder.getRexBuilder().makeCall(FlinkSqlOperatorTable.PROCTIME))
-                        .join(
+                        .filter(
+                                builder.equals(
+                                        builder.field(
+                                                builder.getRexBuilder().makeCorrel(aType, cid),
+                                                "a"),
+                                        builder.getRexBuilder().makeInputRef(aType, 0)))
+                        .correlate(
                                 JoinRelType.INNER,
-                                builder.equals(builder.field(2, 0, "a"), builder.field(2, 1, "a")))
+                                cid,
+                                builder.getRexBuilder().makeInputRef(aType, 0),
+                                builder.getRexBuilder().makeInputRef(ptsType, 1))
                         .project(builder.field(1, 0, "a"))
-                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("lookup", false, true))
+                        .hints(RelHint.builder(FlinkHints.HINT_ALIAS).hintOption("t1").build())
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("d", true, false))
                         .build();
         verifyRelPlan(root);
     }
 
     @Test
-    public void testClearLookupHintWithInvalidPropagationToViewWhileViewHasLookupHints() {
-        // SELECT /*+ LOOKUP('table'='lookup', 'retry-predicate'='lookup_miss',
-        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10') ) */ *
-        //   FROM (
-        //     SELECT /*+ LOOKUP('table'='lookup', 'async'='true', 'output-mode'='allow_unordered',
-        // 'capacity'='1000', 'time-out'='300 s'
-        //       src.a, src.proctime
-        //     FROM src
-        //       JOIN lookup FOR SYSTEM_TIME AS OF T.proctime AS D
-        //         ON T.a = D.id
-        //     ) t1 JOIN lookup FOR SYSTEM_TIME AS OF t1.proctime AS t2 ON t1.a = t2.a
+    public void testClearLookupHintWithInvalidPropagationToSubQuery() {
+        // SELECT /*+ LOOKUP('table'='src', 'retry-predicate'='lookup_miss',
+        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        // */ t1.a
+        //  FROM (
+        //      SELECT s.a
+        //      FROM src s
+        //      JOIN lookup FOR SYSTEM_TIME AS OF s.pts AS d
+        //      ON s.a=d.a
+        //  ) t1
+        //  JOIN src t2
+        //  ON t1.a=t2.a
+
+        CorrelationId cid = builder.getCluster().createCorrel();
+        RelDataType aType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory().createSqlType(SqlTypeName.BIGINT)),
+                                Collections.singletonList("a"));
+        RelDataType ptsType =
+                builder.getTypeFactory()
+                        .createStructType(
+                                Collections.singletonList(
+                                        builder.getTypeFactory()
+                                                .createProctimeIndicatorType(false)),
+                                Collections.singletonList("pts"));
         RelNode root =
                 builder.scan("src")
                         .scan("lookup")
                         .snapshot(builder.getRexBuilder().makeCall(FlinkSqlOperatorTable.PROCTIME))
-                        .join(
+                        .filter(
+                                builder.equals(
+                                        builder.field(
+                                                builder.getRexBuilder().makeCorrel(aType, cid),
+                                                "a"),
+                                        builder.getRexBuilder().makeInputRef(aType, 0)))
+                        .correlate(
                                 JoinRelType.INNER,
-                                builder.equals(builder.field(2, 0, "a"), builder.field(2, 1, "a")))
+                                cid,
+                                builder.getRexBuilder().makeInputRef(aType, 0),
+                                builder.getRexBuilder().makeInputRef(ptsType, 1))
                         .project(builder.field(1, 0, "a"))
-                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("lookup", false, true))
                         .hints(RelHint.builder(FlinkHints.HINT_ALIAS).hintOption("t1").build())
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("d", true, false))
                         .scan("src")
-                        .snapshot(builder.getRexBuilder().makeCall(FlinkSqlOperatorTable.PROCTIME))
+                        .hints(RelHint.builder(FlinkHints.HINT_ALIAS).hintOption("t2").build())
                         .join(
                                 JoinRelType.INNER,
                                 builder.equals(builder.field(2, 0, "a"), builder.field(2, 1, "a")))
                         .project(builder.field(1, 0, "a"))
-                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("lookup", true, false))
+                        .hints(LookupJoinHintTestUtil.getLookupJoinHint("src", true, true))
                         .build();
         verifyRelPlan(root);
     }
 
     @Test
-    public void testClearLookupHintWithInvalidPropagationToSubQuery() {
-        // SELECT /*+ LOOKUP('table'='lookup', 'retry-predicate'='lookup_miss',
-        // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
-        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s' */*
-        //   FROM (
-        //     SELECT src.a
-        //     FROM src
-        //     JOIN lookup FOR SYSTEM_TIME AS OF T.proctime AS D
-        //       ON T.a = D.id
-        //   ) t1 JOIN src t2 ON t1.a = t2.a
+    public void testNoNeedToClearLookupHintWhileJoinWithUnnest() {
+        //  SELECT /*+ LOOKUP('table'='d', 'retry-predicate'='lookup_miss',
+        //  'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        //  'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        //  */ s.a
+        //  FROM src s
+        //  CROSS JOIN UNNEST(s.ds) AS d(a)
+
+        System.out.println(

Review Comment:
   the debug info should be 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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1439466347

   @flinkbot run azure


-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1423550793

   @flinkbot run azure


-- 
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


[GitHub] [flink] Mulavar commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1058069998


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHints.java:
##########
@@ -189,18 +191,33 @@ public static RelNode capitalizeJoinHints(RelNode root) {
 
     private static class CapitalizeJoinHintShuttle extends RelShuttleImpl {
 
+        @Override
+        public RelNode visit(LogicalCorrelate correlate) {
+            return visitBiRel(correlate);
+        }
+
         @Override
         public RelNode visit(LogicalJoin join) {
-            List<RelHint> hints = join.getHints();
+            return visitBiRel(join);
+        }
+
+        private RelNode visitBiRel(BiRel biRel) {
+            Hintable hBiRel = (Hintable) biRel;
             AtomicBoolean changed = new AtomicBoolean(false);
             List<RelHint> hintsWithCapitalJoinHints =
-                    hints.stream()
+                    hBiRel.getHints().stream()
                             .map(
                                     hint -> {
                                         String capitalHintName =
                                                 hint.hintName.toUpperCase(Locale.ROOT);
                                         if (JoinStrategy.isJoinStrategy(capitalHintName)) {
                                             changed.set(true);
+                                            if (JoinStrategy.isLookupHint(hint.hintName)) {

Review Comment:
   please refer to `ClearJoinHintWithCapitalizeJoinHintShuttleTest`.



-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1118010327


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/join/LookupJoinTest.scala:
##########
@@ -951,6 +951,58 @@ class LookupJoinTest(legacyTableSource: Boolean) extends TableTestBase with Seri
     util.verifyExplain(stmt, ExplainDetail.JSON_EXECUTION_PLAN)
   }
 
+  @Test
+  def testJoinWithLookupJoinHint(): Unit = {
+    util.verifyExecPlan(
+      """
+        |SELECT /*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss',
+        |'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
+        |'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        |*/
+        |T.a
+        |FROM MyTable AS T
+        |JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D
+        |ON T.a = D.id
+        |""".stripMargin
+    )
+  }
+
+  @Test
+  def testJoinWithCapitalizeLookupJoinHint(): Unit = {

Review Comment:
   nit: rename to 'testJoinWithMixedCaseLookupJoinHint'



##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/UnnestTest.scala:
##########
@@ -17,10 +17,25 @@
  */
 package org.apache.flink.table.planner.plan.stream.sql
 
+import org.apache.flink.api.scala._
+import org.apache.flink.table.api._
 import org.apache.flink.table.planner.plan.common.UnnestTestBase
 import org.apache.flink.table.planner.utils.TableTestUtil
 
+import org.junit.Test
+
 class UnnestTest extends UnnestTestBase(true) {
 
   override def getTableTestUtil: TableTestUtil = streamTestUtil()
+
+  @Test
+  def testUnnestWithLookupJoinHint(): Unit = {

Review Comment:
   nit: rename to 'testUnnestWithInvalidLookupJoinHint'



##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/join/LookupJoinTest.scala:
##########
@@ -951,6 +951,58 @@ class LookupJoinTest(legacyTableSource: Boolean) extends TableTestBase with Seri
     util.verifyExplain(stmt, ExplainDetail.JSON_EXECUTION_PLAN)
   }
 
+  @Test
+  def testJoinWithLookupJoinHint(): Unit = {

Review Comment:
   this can be merge with the 'testJoinWithInvalidPropagationToSubQuery', rename to 'testJoinHintWithNoPropagatingToSubQuery'



-- 
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


[GitHub] [flink] lincoln-lil commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1445277785

   @Mulavar could you also create a backport pr to release-1.17 branch? 


-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1442717916

   @flinkbot run azure


-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1055433378


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/alias/ClearJoinHintWithInvalidPropagationShuttle.java:
##########
@@ -49,14 +52,23 @@ public class ClearJoinHintWithInvalidPropagationShuttle extends RelShuttleImpl {
 
     @Override
     public RelNode visit(LogicalJoin join) {
-        List<RelHint> hints = join.getHints();
+        return visitBiRel(join);
+    }
+
+    @Override
+    public RelNode visit(LogicalCorrelate correlate) {
+        return visitBiRel(correlate);
+    }
+
+    public RelNode visitBiRel(BiRel biRel) {

Review Comment:
   this can be private



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHintStrategies.java:
##########
@@ -62,8 +62,10 @@ public static HintStrategyTable createHintStrategyTable() {
                 // internal join hint used for alias
                 .hintStrategy(
                         FlinkHints.HINT_ALIAS,
-                        // currently, only join hints care about query block alias
-                        HintStrategy.builder(HintPredicates.JOIN)
+                        // currently, only correlate&join hints care about query block alias
+                        HintStrategy.builder(
+                                        HintPredicates.or(
+                                                HintPredicates.CORRELATE, HintPredicates.JOIN))
                                 .optionChecker(fixedSizeListOptionChecker(1))

Review Comment:
   the fixedSizeListOptionChecker is not applicable to CORRELATE  (actually the lookup join which only accepts kvOptions)



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHints.java:
##########
@@ -189,18 +192,33 @@ public static RelNode capitalizeJoinHints(RelNode root) {
 
     private static class CapitalizeJoinHintShuttle extends RelShuttleImpl {
 
+        @Override
+        public RelNode visit(LogicalCorrelate correlate) {
+            return visitBiRel(correlate);
+        }
+
         @Override
         public RelNode visit(LogicalJoin join) {
-            List<RelHint> hints = join.getHints();
+            return visitBiRel(join);
+        }
+
+        public RelNode visitBiRel(BiRel biRel) {

Review Comment:
   can be private



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/alias/ClearLookupCorrelateHintWithInvalidPropagationShuttleTest.java:
##########
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.alias;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.planner.functions.sql.FlinkSqlOperatorTable;
+import org.apache.flink.table.planner.hint.FlinkHints;
+import org.apache.flink.table.planner.plan.nodes.exec.spec.LookupJoinHintTestUtil;
+import org.apache.flink.table.planner.utils.TableTestUtil;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.CorrelationId;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.hint.RelHint;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/** Tests clearing lookup join hint with invalid propagation in stream. */
+public class ClearLookupCorrelateHintWithInvalidPropagationShuttleTest

Review Comment:
   It's better to fix the current ClearLookupJoinHintWithInvalidPropagationShuttleTest instead of add another 'LookupCorrelate' test since the lookup join is always converted from a LogicalCorrelate, WDYT?



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHints.java:
##########
@@ -189,18 +192,33 @@ public static RelNode capitalizeJoinHints(RelNode root) {
 
     private static class CapitalizeJoinHintShuttle extends RelShuttleImpl {
 
+        @Override
+        public RelNode visit(LogicalCorrelate correlate) {
+            return visitBiRel(correlate);
+        }
+
         @Override
         public RelNode visit(LogicalJoin join) {
-            List<RelHint> hints = join.getHints();
+            return visitBiRel(join);
+        }
+
+        public RelNode visitBiRel(BiRel biRel) {
+            Hintable hBiRel = (Hintable) biRel;
             AtomicBoolean changed = new AtomicBoolean(false);
             List<RelHint> hintsWithCapitalJoinHints =
-                    hints.stream()
+                    hBiRel.getHints().stream()
                             .map(
                                     hint -> {
                                         String capitalHintName =
                                                 hint.hintName.toUpperCase(Locale.ROOT);
                                         if (JoinStrategy.isJoinStrategy(capitalHintName)) {
                                             changed.set(true);
+                                            if (hint.listOptions.isEmpty()) {

Review Comment:
   We'd better to distinguish the kvOption and listOption via different hint but not the option itself, here we can use `isLookupHint` to determine



-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1422265099

   I forth-push the pr to edit the author of the commit, there's no more code edit.


-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1422250914

   @lincoln-lil @godfreyhe hi, please check the latest commit, I've added UNNEST and LATERAL TABLE cases for the pr.


-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1363960725

   @flinkbot run azure


-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1115683129


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/join/LookupJoinTest.scala:
##########
@@ -951,6 +953,39 @@ class LookupJoinTest(legacyTableSource: Boolean) extends TableTestBase with Seri
     util.verifyExplain(stmt, ExplainDetail.JSON_EXECUTION_PLAN)
   }
 
+  @Test
+  def testJoinWithLookupJoinHint(): Unit = {
+    val sql = "SELECT /*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', " +
+      "'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10', " +
+      "'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')  */ " +
+      "T.a FROM MyTable AS T JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id"
+
+    util.verifyExecPlan(sql)
+  }
+
+  @Test
+  def testJoinInvalidUDTFWithLookupJoinHint(): Unit = {

Review Comment:
   we should move this case into CorrelateTest or JoinTest since uses lateral table.



##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/join/LookupJoinTest.scala:
##########
@@ -951,6 +953,39 @@ class LookupJoinTest(legacyTableSource: Boolean) extends TableTestBase with Seri
     util.verifyExplain(stmt, ExplainDetail.JSON_EXECUTION_PLAN)
   }
 
+  @Test
+  def testJoinWithLookupJoinHint(): Unit = {
+    val sql = "SELECT /*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', " +
+      "'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10', " +
+      "'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')  */ " +
+      "T.a FROM MyTable AS T JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id"
+
+    util.verifyExecPlan(sql)
+  }
+
+  @Test
+  def testJoinInvalidUDTFWithLookupJoinHint(): Unit = {
+    // not support to extract table name from udtf now
+    expectExceptionThrown(
+      "SELECT /*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', " +
+        "'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10', " +
+        "'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s') */ " +
+        "T.a FROM MyTable AS T CROSS JOIN LATERAL TABLE(MockUDTF(a)) AS D(b)",
+      "The options of following hints cannot match the name of input tables or views: \n" +
+        "`D` in `LOOKUP`"
+    )
+  }
+
+  @Test
+  def testJoinUnnestWithLookupJoinHint(): Unit = {

Review Comment:
   This should be moved into UnnestTest



-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1440268275

   @lincoln-lil @godfreyhe hello, thanks for u suggestions!
   I've added sql cases for this pr, do u have any time to take a look again?


-- 
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


[GitHub] [flink] lincoln-lil commented on a diff in pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
lincoln-lil commented on code in PR #21545:
URL: https://github.com/apache/flink/pull/21545#discussion_r1055969354


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/alias/ClearLookupJoinHintWithInvalidPropagationShuttleTest.java:
##########
@@ -120,22 +125,53 @@ public void testClearLookupHintWithInvalidPropagationToViewWhileViewHasLookupHin
     public void testClearLookupHintWithInvalidPropagationToSubQuery() {
         // SELECT /*+ LOOKUP('table'='lookup', 'retry-predicate'='lookup_miss',
         // 'retry-strategy'='fixed_delay', 'fixed-delay'='155 ms', 'max-attempts'='10',
-        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s' */*
-        //   FROM (
-        //     SELECT src.a
-        //     FROM src
-        //     JOIN lookup FOR SYSTEM_TIME AS OF T.proctime AS D
-        //       ON T.a = D.id
-        //   ) t1 JOIN src t2 ON t1.a = t2.a
+        // 'async'='true', 'output-mode'='allow_unordered','capacity'='1000', 'time-out'='300 s')
+        // */ t1.a
+        //  FROM (
+        //      SELECT s.a
+        //      FROM src s
+        //      JOIN lookup FOR SYSTEM_TIME AS OF s.pts AS d
+        //      ON s.a=d.a
+        //  ) t1
+        //  JOIN src t2
+        //  ON t1.a=t2.a
+
+        CorrelationId cid = builder.getCluster().createCorrel();
+        RelDataType aType = builder
+                .getTypeFactory()
+                .createStructType(
+                        Arrays.asList(builder.getTypeFactory().createSqlType(SqlTypeName.BIGINT)),
+                        Arrays.asList("a")

Review Comment:
   nit: 'Arrays.asList' on single element can be replaced with 'Collections.singletonList'



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHintStrategies.java:
##########
@@ -62,8 +62,10 @@ public static HintStrategyTable createHintStrategyTable() {
                 // internal join hint used for alias
                 .hintStrategy(
                         FlinkHints.HINT_ALIAS,
-                        // currently, only join hints care about query block alias
-                        HintStrategy.builder(HintPredicates.JOIN)
+                        // currently, only correlate&join hints care about query block alias
+                        HintStrategy.builder(
+                                        HintPredicates.or(
+                                                HintPredicates.CORRELATE, HintPredicates.JOIN))
                                 .optionChecker(fixedSizeListOptionChecker(1))

Review Comment:
   sorry, my misunderstood here, this optionChecker is ok.



-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1367773355

   @godfreyhe hi, could u check this pr again? I've add a new test case to verify the change.


-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1422239410

   @flinkbot run azure


-- 
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


[GitHub] [flink] Mulavar commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "Mulavar (via GitHub)" <gi...@apache.org>.
Mulavar commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1423553998

   @flinkbot run azure


-- 
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


[GitHub] [flink] lincoln-lil commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1423926126

   @Mulavar  the e2e failure phase "Prepare E2E run" has been fixed by FLINK-30972, you can rebase the code and update this pr


-- 
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


[GitHub] [flink] lincoln-lil commented on pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by GitBox <gi...@apache.org>.
lincoln-lil commented on PR #21545:
URL: https://github.com/apache/flink/pull/21545#issuecomment-1377022546

   @Mulavar as suggested by @godfreyhe before, more correlate query related test cases need to be added for `Correlate` node changes, e.g., "select ... from t, lateral table(tableFunc1(f1)) as T(t1)" or "SELECT ... FROM MyTable, UNNEST(MyTable.c) as A (s)" and etc.


-- 
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


[GitHub] [flink] lincoln-lil closed pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil closed pull request #21545: [FLINK-30396][table]make alias hint take effect in correlate
URL: https://github.com/apache/flink/pull/21545


-- 
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