wuchong commented on a change in pull request #11985: URL: https://github.com/apache/flink/pull/11985#discussion_r421916467
########## File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/runtime/batch/sql/DynamicTableSourceITCase.scala ########## @@ -0,0 +1,255 @@ +/* + * 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.runtime.batch.sql + +import org.apache.flink.table.planner.factories.TestValuesTableFactory +import org.apache.flink.table.planner.runtime.utils.BatchTestBase.row +import org.apache.flink.table.planner.runtime.utils.{BatchTestBase, TestData} +import org.apache.flink.table.planner.utils._ +import org.apache.flink.types.Row + +import org.junit.{Before, Test} + +import java.lang.{Boolean => JBool, Integer => JInt, Long => JLong} + +class DynamicTableSourceITCase extends BatchTestBase { + + @Before + override def before(): Unit = { + super.before() + env.setParallelism(1) // set sink parallelism to 1 + val myTableDataId = TestValuesTableFactory.registerData(TestData.smallData3) + tEnv.executeSql( + s""" + |CREATE TABLE MyTable ( + | `a` INT, + | `b` BIGINT, + | `c` STRING + |) WITH ( + | 'connector' = 'values', + | 'data-id' = '$myTableDataId', + | 'bounded' = 'true' + |) + |""".stripMargin) + + val filterableTableDataId = TestValuesTableFactory.registerData( + TestFilterableTableSource.defaultRows) + // TODO: [FLINK-17425] support filter pushdown for TestValuesTableSource + tEnv.executeSql( + s""" + |CREATE TABLE FilterableTable ( + | name STRING, + | id BIGINT, + | amount INT, + | price DOUBLE + |) WITH ( + | 'connector' = 'values', + | 'data-id' = '$filterableTableDataId', + | 'bounded' = 'true' + |) + |""".stripMargin) + } + + @Test + def testSimpleProject(): Unit = { + checkResult( + "SELECT a, c FROM MyTable", + Seq( + row(1, "Hi"), + row(2, "Hello"), + row(3, "Hello world")) + ) + } + + @Test + def testProjectWithoutInputRef(): Unit = { + checkResult( + "SELECT COUNT(*) FROM MyTable", + Seq(row(3)) + ) + } + + @Test + def testNestedProject(): Unit = { + val data = Seq( + Row.of(new JLong(1), + Row.of( + Row.of("Sarah", new JInt(100)), + Row.of(new JInt(1000), new JBool(true)) + ), + Row.of("Peter", new JInt(10000)), + "Mary"), + Row.of(new JLong(2), + Row.of( + Row.of("Rob", new JInt(200)), + Row.of(new JInt(2000), new JBool(false)) + ), + Row.of("Lucy", new JInt(20000)), + "Bob"), + Row.of(new JLong(3), + Row.of( + Row.of("Mike", new JInt(300)), + Row.of(new JInt(3000), new JBool(true)) + ), + Row.of("Betty", new JInt(30000)), + "Liz")) + + val dataId = TestValuesTableFactory.registerData(data) + + // TODO: [FLINK-17428] support nested project for TestValuesTableSource + val ddl = Review comment: Sure. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org