snuyanzin commented on code in PR #30097:
URL: https://github.com/apache/flink/pull/30097#discussion_r4708515102


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/utils/NestedProjectionUtilJoinTest.java:
##########
@@ -0,0 +1,488 @@
+/*
+ * 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.plan.utils;
+
+import org.apache.flink.table.planner.calcite.FlinkRexBuilder;
+import org.apache.flink.table.planner.calcite.FlinkTypeFactory;
+import org.apache.flink.table.planner.calcite.FlinkTypeSystem;
+
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.validate.SqlValidatorUtil;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link NestedProjectionUtil#rewriteForJoin} and {@code 
hasPrunableNestedLeaf}. */
+class NestedProjectionUtilJoinTest {
+
+    private final FlinkTypeFactory typeFactory =
+            new FlinkTypeFactory(
+                    Thread.currentThread().getContextClassLoader(), 
FlinkTypeSystem.INSTANCE);
+    private final RexBuilder rexBuilder = new FlinkRexBuilder(typeFactory);
+
+    // 
------------------------------------------------------------------------------------------
+    // rewriteForJoin
+    // 
------------------------------------------------------------------------------------------
+
+    @Test
+    void testLeavesAreSplitPerSideInInputOrder() {
+        // Structs are referenced out of their column order and two leaves of 
s1 are used. The
+        // unused column k sits between them and passes through whole.
+        final RelDataType left =
+                row(
+                        "id", intType(),
+                        "s1", row("a", intType(), "b", intType()),
+                        "k", intType(),
+                        "s2", row("c", intType(), "d", intType()));
+        final RelDataType right = row("id2", intType(), "t", row("e", 
intType(), "f", intType()));
+        final RelDataType join = concat(left, right);
+
+        final JoinNestedProjectionResult result =
+                rewrite(
+                        List.of(
+                                access(join, 3, "d"),
+                                access(join, 1, "a"),
+                                access(join, 1, "b"),
+                                access(join, 5, "f")),
+                        equals(ref(join, 0), ref(join, 4)),
+                        join,
+                        left,
+                        right);
+
+        assertThat(strings(result.leftProjects()))
+                .containsExactly("$0", "$1.a", "$1.b", "$2", "$3.d");
+        assertThat(strings(result.rightProjects())).containsExactly("$0", 
"$1.f");
+        assertThat(strings(result.rewrittenProjects())).containsExactly("$4", 
"$1", "$2", "$6");
+        assertThat(result.rewrittenCondition().toString()).isEqualTo("=($0, 
$5)");

Review Comment:
   ```suggestion
           assertThat(result.rewrittenCondition()).hasToString("=($0, $5)");
   ```



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