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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to