PHILO-HE commented on code in PR #10180:
URL: 
https://github.com/apache/incubator-gluten/pull/10180#discussion_r2206822220


##########
gluten-flink/ut/src/test/java/org/apache/gluten/streaming/api/operators/GlutenStreamJoinOperatorTestBase.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.gluten.streaming.api.operators;
+
+import org.apache.gluten.rexnode.RexConversionContext;
+import org.apache.gluten.rexnode.RexNodeConverter;
+import org.apache.gluten.rexnode.Utils;
+import org.apache.gluten.table.runtime.operators.GlutenVectorTwoInputOperator;
+import org.apache.gluten.table.runtime.stream.common.Velox4jEnvironment;
+import org.apache.gluten.util.LogicalTypeConverter;
+import org.apache.gluten.util.PlanNodeIdGenerator;
+import org.apache.gluten.vectorized.FlinkRowToVLVectorConvertor;
+
+import io.github.zhztheplayer.velox4j.Velox4j;
+import io.github.zhztheplayer.velox4j.connector.ExternalStreamTableHandle;
+import io.github.zhztheplayer.velox4j.data.RowVector;
+import io.github.zhztheplayer.velox4j.expression.CallTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.FieldAccessTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.TypedExpr;
+import io.github.zhztheplayer.velox4j.join.JoinType;
+import io.github.zhztheplayer.velox4j.memory.AllocationListener;
+import io.github.zhztheplayer.velox4j.memory.MemoryManager;
+import io.github.zhztheplayer.velox4j.plan.EmptyNode;
+import io.github.zhztheplayer.velox4j.plan.NestedLoopJoinNode;
+import io.github.zhztheplayer.velox4j.plan.PlanNode;
+import io.github.zhztheplayer.velox4j.plan.StatefulPlanNode;
+import io.github.zhztheplayer.velox4j.plan.StreamJoinNode;
+import io.github.zhztheplayer.velox4j.plan.TableScanNode;
+import io.github.zhztheplayer.velox4j.session.Session;
+import io.github.zhztheplayer.velox4j.stateful.StatefulRecord;
+import io.github.zhztheplayer.velox4j.type.BooleanType;
+import io.github.zhztheplayer.velox4j.type.RowType;
+
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.TwoInputStreamOperatorTestHarness;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+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.flink.table.runtime.operators.join.FlinkJoinType;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.logical.CharType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.VarCharType;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public abstract class GlutenStreamJoinOperatorTestBase {
+
+  protected static FlinkTypeFactory typeFactory;
+  protected static RexBuilder rexBuilder;
+
+  protected static org.apache.flink.table.types.logical.RowType leftRowType;
+  protected static InternalTypeInfo<RowData> leftTypeInfo;
+  protected static RowType leftVeloxType;
+
+  protected static org.apache.flink.table.types.logical.RowType rightRowType;
+  protected static InternalTypeInfo<RowData> rightTypeInfo;
+  protected static RowType rightVeloxType;
+
+  protected static org.apache.flink.table.types.logical.RowType outputRowType;
+  protected static InternalTypeInfo<RowData> outputTypeInfo;
+  protected static RowType outputVeloxType;
+
+  protected static final int[] leftJoinKeys = {1};
+  protected static final int[] rightJoinKeys = {0};

Review Comment:
   Move to the calling place if it is not used and will not be used in other 
places.



##########
gluten-flink/ut/src/test/java/org/apache/gluten/streaming/api/operators/GlutenStreamJoinOperatorTestBase.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.gluten.streaming.api.operators;
+
+import org.apache.gluten.rexnode.RexConversionContext;
+import org.apache.gluten.rexnode.RexNodeConverter;
+import org.apache.gluten.rexnode.Utils;
+import org.apache.gluten.table.runtime.operators.GlutenVectorTwoInputOperator;
+import org.apache.gluten.table.runtime.stream.common.Velox4jEnvironment;
+import org.apache.gluten.util.LogicalTypeConverter;
+import org.apache.gluten.util.PlanNodeIdGenerator;
+import org.apache.gluten.vectorized.FlinkRowToVLVectorConvertor;
+
+import io.github.zhztheplayer.velox4j.Velox4j;
+import io.github.zhztheplayer.velox4j.connector.ExternalStreamTableHandle;
+import io.github.zhztheplayer.velox4j.data.RowVector;
+import io.github.zhztheplayer.velox4j.expression.CallTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.FieldAccessTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.TypedExpr;
+import io.github.zhztheplayer.velox4j.join.JoinType;
+import io.github.zhztheplayer.velox4j.memory.AllocationListener;
+import io.github.zhztheplayer.velox4j.memory.MemoryManager;
+import io.github.zhztheplayer.velox4j.plan.EmptyNode;
+import io.github.zhztheplayer.velox4j.plan.NestedLoopJoinNode;
+import io.github.zhztheplayer.velox4j.plan.PlanNode;
+import io.github.zhztheplayer.velox4j.plan.StatefulPlanNode;
+import io.github.zhztheplayer.velox4j.plan.StreamJoinNode;
+import io.github.zhztheplayer.velox4j.plan.TableScanNode;
+import io.github.zhztheplayer.velox4j.session.Session;
+import io.github.zhztheplayer.velox4j.stateful.StatefulRecord;
+import io.github.zhztheplayer.velox4j.type.BooleanType;
+import io.github.zhztheplayer.velox4j.type.RowType;
+
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.TwoInputStreamOperatorTestHarness;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+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.flink.table.runtime.operators.join.FlinkJoinType;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.logical.CharType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.VarCharType;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public abstract class GlutenStreamJoinOperatorTestBase {

Review Comment:
   Looks the difference is big between this class and Flink's 
`StreamJoinOperatorTestBase`. Can the code in that class be reused here through 
extending?



##########
gluten-flink/ut/src/test/java/org/apache/gluten/streaming/api/operators/GlutenStreamJoinOperatorTest.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * 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.gluten.streaming.api.operators;
+
+import org.apache.gluten.table.runtime.operators.GlutenVectorTwoInputOperator;
+
+import io.github.zhztheplayer.velox4j.stateful.StatefulRecord;
+
+import org.apache.flink.streaming.util.TwoInputStreamOperatorTestHarness;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.runtime.operators.join.FlinkJoinType;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static 
org.apache.gluten.streaming.api.operators.utils.RowDataTestUtils.checkEquals;
+
+public class GlutenStreamJoinOperatorTest extends 
GlutenStreamJoinOperatorTestBase {
+
+  @Test
+  public void testInnerJoin() throws Exception {
+    GlutenVectorTwoInputOperator operator = 
createJoinOperator(FlinkJoinType.INNER);
+    TwoInputStreamOperatorTestHarness<StatefulRecord, StatefulRecord, RowData> 
harness =
+        createTestHarness(operator);
+
+    processLeftTestData(harness, leftTestData);
+    processRightTestData(harness, rightTestData);
+
+    List<RowData> actualOutput = extractOutputFromHarness(harness);
+
+    List<RowData> expectedOutput =
+        Arrays.asList(
+            GenericRowData.of(
+                StringData.fromString("Ord#1"),
+                StringData.fromString("LineOrd#2"),
+                StringData.fromString("3 Bellevue Drive, Pottstown, PA 19464"),
+                StringData.fromString("LineOrd#2"),
+                StringData.fromString("AIR")),
+            GenericRowData.of(
+                StringData.fromString("Ord#2"),
+                StringData.fromString("LineOrd#3"),
+                StringData.fromString("68 Manor Station Street, Honolulu, HI 
96815"),
+                StringData.fromString("LineOrd#3"),
+                StringData.fromString("TRUCK")));
+
+    checkEquals(actualOutput, expectedOutput, outputRowType.getChildren());
+    harness.close();

Review Comment:
   Seems the code of these test methods can be unified into a util method with 
join operator and expected result as inputs. Then, in each test, only call this 
util method.



##########
gluten-flink/ut/src/test/java/org/apache/gluten/streaming/api/operators/GlutenStreamJoinOperatorTest.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * 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.gluten.streaming.api.operators;
+
+import org.apache.gluten.table.runtime.operators.GlutenVectorTwoInputOperator;
+
+import io.github.zhztheplayer.velox4j.stateful.StatefulRecord;
+
+import org.apache.flink.streaming.util.TwoInputStreamOperatorTestHarness;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.runtime.operators.join.FlinkJoinType;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static 
org.apache.gluten.streaming.api.operators.utils.RowDataTestUtils.checkEquals;
+
+public class GlutenStreamJoinOperatorTest extends 
GlutenStreamJoinOperatorTestBase {
+
+  @Test
+  public void testInnerJoin() throws Exception {
+    GlutenVectorTwoInputOperator operator = 
createJoinOperator(FlinkJoinType.INNER);
+    TwoInputStreamOperatorTestHarness<StatefulRecord, StatefulRecord, RowData> 
harness =
+        createTestHarness(operator);
+
+    processLeftTestData(harness, leftTestData);
+    processRightTestData(harness, rightTestData);
+
+    List<RowData> actualOutput = extractOutputFromHarness(harness);
+
+    List<RowData> expectedOutput =
+        Arrays.asList(
+            GenericRowData.of(
+                StringData.fromString("Ord#1"),
+                StringData.fromString("LineOrd#2"),
+                StringData.fromString("3 Bellevue Drive, Pottstown, PA 19464"),
+                StringData.fromString("LineOrd#2"),
+                StringData.fromString("AIR")),
+            GenericRowData.of(
+                StringData.fromString("Ord#2"),
+                StringData.fromString("LineOrd#3"),
+                StringData.fromString("68 Manor Station Street, Honolulu, HI 
96815"),
+                StringData.fromString("LineOrd#3"),
+                StringData.fromString("TRUCK")));
+
+    checkEquals(actualOutput, expectedOutput, outputRowType.getChildren());
+    harness.close();
+  }
+
+  @Test
+  @Disabled
+  public void testLeftJoin() throws Exception {
+    GlutenVectorTwoInputOperator operator = 
createJoinOperator(FlinkJoinType.LEFT);
+    TwoInputStreamOperatorTestHarness<StatefulRecord, StatefulRecord, RowData> 
harness =
+        createTestHarness(operator);
+
+    processLeftTestData(harness, leftTestData);
+    processRightTestData(harness, rightTestData);
+
+    List<RowData> actualOutput = extractOutputFromHarness(harness);
+
+    List<RowData> expectedOutput =
+        Arrays.asList(
+            GenericRowData.of(
+                StringData.fromString("Ord#1"),
+                StringData.fromString("LineOrd#1"),
+                StringData.fromString("3 Bellevue Drive, Pottstown, PA 19464"),
+                null,
+                null),
+            GenericRowData.of(
+                StringData.fromString("Ord#1"),
+                StringData.fromString("LineOrd#2"),
+                StringData.fromString("3 Bellevue Drive, Pottstown, PA 19464"),
+                StringData.fromString("LineOrd#2"),
+                StringData.fromString("AIR")),
+            GenericRowData.of(
+                StringData.fromString("Ord#2"),
+                StringData.fromString("LineOrd#3"),
+                StringData.fromString("68 Manor Station Street, Honolulu, HI 
96815"),
+                StringData.fromString("LineOrd#3"),
+                StringData.fromString("TRUCK")));
+
+    checkEquals(actualOutput, expectedOutput, outputRowType.getChildren());
+    harness.close();
+  }
+
+  @Test
+  @Disabled
+  public void testRightJoin() throws Exception {
+    GlutenVectorTwoInputOperator operator = 
createJoinOperator(FlinkJoinType.RIGHT);
+    TwoInputStreamOperatorTestHarness<StatefulRecord, StatefulRecord, RowData> 
harness =
+        createTestHarness(operator);
+
+    processLeftTestData(harness, leftTestData);
+    processRightTestData(harness, rightTestData);
+
+    List<RowData> actualOutput = extractOutputFromHarness(harness);
+
+    List<RowData> expectedOutput =
+        Arrays.asList(
+            GenericRowData.of(
+                StringData.fromString("Ord#1"),

Review Comment:
   Import `StringData.fromString` to remove the use of `StringData` for brevity.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to