xuyangzhong commented on a change in pull request #17771: URL: https://github.com/apache/flink/pull/17771#discussion_r748953720
########## File path: flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ImplicitConversionEqualsFunctionITCase.java ########## @@ -0,0 +1,227 @@ +/* + * 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.functions; + +import org.apache.flink.table.functions.BuiltInFunctionDefinitions; +import org.apache.flink.table.types.AbstractDataType; +import org.apache.flink.table.types.DataType; + +import org.junit.runners.Parameterized; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.apache.flink.table.api.DataTypes.BIGINT; +import static org.apache.flink.table.api.DataTypes.BOOLEAN; +import static org.apache.flink.table.api.DataTypes.DATE; +import static org.apache.flink.table.api.DataTypes.DECIMAL; +import static org.apache.flink.table.api.DataTypes.DOUBLE; +import static org.apache.flink.table.api.DataTypes.FLOAT; +import static org.apache.flink.table.api.DataTypes.INT; +import static org.apache.flink.table.api.DataTypes.SMALLINT; +import static org.apache.flink.table.api.DataTypes.STRING; +import static org.apache.flink.table.api.DataTypes.TIME; +import static org.apache.flink.table.api.DataTypes.TIMESTAMP; +import static org.apache.flink.table.api.DataTypes.TINYINT; + +/** Tests for type conversions in '='. */ +public class ImplicitConversionEqualsFunctionITCase extends BuiltInFunctionTestBase { + + // numeric data + private static final byte TINY_INT_DATA = (byte) 1; + private static final short SMALL_INT_DATA = (short) 1; + private static final int INT_DATA = 1; + private static final long BIG_INT_DATA = 1L; + private static final float FLOAT_DATA = 1.0f; + private static final double DOUBLE_DATA = 1.0d; + private static final BigDecimal DECIMAL_DATA = new BigDecimal(1); + + // time data + private static final String DATE_DATA = "2001-01-01"; + private static final String TIME_DATA = "00:00:00"; + private static final String TIMESTAMP_DATA = ("2001-01-01 00:00:00"); + + // string data + private static final String STRING_DATA_EQUALS_NUMERIC = "1"; + private static final String STRING_DATA_EQUALS_DATE = "2001-01-01"; + private static final String STRING_DATA_EQUALS_TIME = "00:00:00"; + private static final String STRING_DATA_EQUALS_TIMESTAMP = "2001-01-01 00:00:00"; + + @Parameterized.Parameters(name = "{index}: {0}") + public static List<TestSpec> testData() { + final List<TestSpec> specs = new ArrayList<>(); + specs.addAll(implicitConversionBetweenNumeric()); + specs.addAll(implicitConversionBetweenTimeAndString()); + specs.addAll(unsupportedImplicitConversionBetweenNumericAndString()); + return specs; + } + + private static List<TestSpec> implicitConversionBetweenNumeric() { + return Arrays.asList( + TypeConversionTestBuilder.left(TINYINT(), TINY_INT_DATA) + .right(TINYINT(), TINY_INT_DATA) + .right(SMALLINT(), SMALL_INT_DATA) + .right(INT(), INT_DATA) + .right(BIGINT(), BIG_INT_DATA) + .right(FLOAT(), FLOAT_DATA) + .right(DOUBLE(), DOUBLE_DATA) + .right(DECIMAL(1, 0), DECIMAL_DATA) Review comment: Yes, because these test cases are about implicit type conversions between different types with function '=' and we only test the case in which the result is TRUE. To ensure the result is TRUE, these values should be same. The reason why we only test TRUE is aimed to verify fixing the bug that implicit type conversion between numeric and (var)char in '=' was always caused FALSE.So in order to test the correctness, it's meaningless to test the result FALSE again. -- 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