twalthr commented on a change in pull request #16691: URL: https://github.com/apache/flink/pull/16691#discussion_r686988846
########## File path: flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/BuiltInFunctionTestBase.java ########## @@ -127,8 +128,19 @@ private static void testTableApiResult( private static void testTableApiError(Table inputTable, TableApiErrorTestItem testItem) { try { - inputTable.select(testItem.expression).execute(); - fail("Error expected: " + testItem.errorMessage); + final TableResult tableResult = inputTable.select(testItem.expression).execute(); Review comment: can we move this refactoring to a separate hotfix commit? It has nothing to do with JSON_EXISTS and is useful without it. ########## File path: flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/inference/strategies/SymbolArgumentTypeStrategyTest.java ########## @@ -0,0 +1,70 @@ +/* + * 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.types.inference.strategies; + +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.expressions.TableSymbol; +import org.apache.flink.table.types.AtomicDataType; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.inference.InputTypeStrategiesTestBase; +import org.apache.flink.table.types.inference.InputTypeStrategy; +import org.apache.flink.table.types.logical.SymbolType; + +import org.junit.runners.Parameterized; + +import java.util.List; + +import static java.util.Arrays.asList; +import static org.apache.flink.table.types.inference.InputTypeStrategies.sequence; +import static org.apache.flink.table.types.inference.InputTypeStrategies.symbol; + +/** Tests for {@link SymbolArgumentTypeStrategy}. */ +public class SymbolArgumentTypeStrategyTest extends InputTypeStrategiesTestBase { + + private static final InputTypeStrategy STRATEGY = sequence(symbol(TestEnum.class)); + + @Parameterized.Parameters(name = "{index}: {0}") + public static List<TestSpec> testData() { + return asList( + TestSpec.forStrategy("Valid argument", STRATEGY) + .calledWithArgumentTypes(makeEnumType(TestEnum.class)) + .calledWithLiteralAt(0, TestEnum.A) + .expectSignature("f(<TestEnum>)"), + TestSpec.forStrategy("Wrong enum", STRATEGY) + .calledWithArgumentTypes(makeEnumType(InvalidEnum.class)) + .calledWithLiteralAt(0, InvalidEnum.A) + .expectErrorMessage("Argument is 'InvalidEnum', but expected 'TestEnum'"), + TestSpec.forStrategy("Wrong type", STRATEGY) + .calledWithArgumentTypes(DataTypes.STRING()) + .expectErrorMessage("Argument is not a symbol type for 'TestEnum'")); Review comment: ``` Unsupported argument type. Expected symbol type '%s' but actual type was '%s'. ``` ########## File path: flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/inference/strategies/SymbolArgumentTypeStrategyTest.java ########## @@ -0,0 +1,70 @@ +/* + * 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.types.inference.strategies; + +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.expressions.TableSymbol; +import org.apache.flink.table.types.AtomicDataType; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.inference.InputTypeStrategiesTestBase; +import org.apache.flink.table.types.inference.InputTypeStrategy; +import org.apache.flink.table.types.logical.SymbolType; + +import org.junit.runners.Parameterized; + +import java.util.List; + +import static java.util.Arrays.asList; +import static org.apache.flink.table.types.inference.InputTypeStrategies.sequence; +import static org.apache.flink.table.types.inference.InputTypeStrategies.symbol; + +/** Tests for {@link SymbolArgumentTypeStrategy}. */ +public class SymbolArgumentTypeStrategyTest extends InputTypeStrategiesTestBase { + + private static final InputTypeStrategy STRATEGY = sequence(symbol(TestEnum.class)); + + @Parameterized.Parameters(name = "{index}: {0}") + public static List<TestSpec> testData() { + return asList( + TestSpec.forStrategy("Valid argument", STRATEGY) + .calledWithArgumentTypes(makeEnumType(TestEnum.class)) + .calledWithLiteralAt(0, TestEnum.A) + .expectSignature("f(<TestEnum>)"), + TestSpec.forStrategy("Wrong enum", STRATEGY) + .calledWithArgumentTypes(makeEnumType(InvalidEnum.class)) + .calledWithLiteralAt(0, InvalidEnum.A) + .expectErrorMessage("Argument is 'InvalidEnum', but expected 'TestEnum'"), Review comment: Maybe we can make this consistent with `ExplicitTypeStrategy`: ``` Unsupported argument symbol type. Expected symbol '%s' but actual symbol was '%s'. ``` -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org