hanyuzheng7 commented on code in PR #29624:
URL: https://github.com/apache/flink/pull/29624#discussion_r4390971154


##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/values/ValuesSourceTest.java:
##########
@@ -0,0 +1,167 @@
+/*
+ * 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.runtime.operators.values;
+
+import org.apache.flink.api.connector.source.ReaderInfo;
+import org.apache.flink.api.connector.source.SourceReader;
+import org.apache.flink.api.connector.source.SplitEnumerator;
+import 
org.apache.flink.api.connector.source.lib.NumberSequenceSource.NumberSequenceSplit;
+import org.apache.flink.api.connector.source.mocks.MockSplitEnumeratorContext;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.testutils.source.reader.TestingReaderContext;
+import org.apache.flink.connector.testutils.source.reader.TestingReaderOutput;
+import org.apache.flink.core.io.InputStatus;
+import org.apache.flink.core.io.SimpleVersionedSerializer;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.runtime.generated.GeneratedInput;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.types.logical.VarCharType;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link ValuesSource}. */
+class ValuesSourceTest {
+
+    private static final int NUM_ROWS = 5;
+
+    private static final String FORMAT_CLASS = "TestValuesInputFormat";
+
+    /** Like the generated VALUES code, this format returns the same row 
object for every row. */
+    private static final String FORMAT_CODE =
+            String.join(
+                    "\n",
+                    "public class " + FORMAT_CLASS,
+                    "        extends 
org.apache.flink.api.common.io.GenericInputFormat {",
+                    "    private int nextRow = 0;",
+                    "    private final 
org.apache.flink.table.data.GenericRowData out =",
+                    "            new 
org.apache.flink.table.data.GenericRowData(1);",
+                    "    public " + FORMAT_CLASS + "(Object[] references) {}",
+                    "    public boolean reachedEnd() {",
+                    "        return nextRow >= " + NUM_ROWS + ";",
+                    "    }",
+                    "    public Object nextRecord(Object reuse) {",
+                    "        out.setField(0, 
org.apache.flink.table.data.binary.BinaryStringData",
+                    "                .fromString(\"row-\" + nextRow++));",
+                    "        return out;",
+                    "    }",
+                    "}");

Review Comment:
   `ValuesCodeGenerator` is in the planner, and this test is in 
`flink-table-runtime`, which doesn't depend on the planner. That's why I wrote 
the class by hand. With the change above, I'll move the test to the planner and 
use `ValuesCodeGenerator`.



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