slinkydeveloper commented on a change in pull request #17256:
URL: https://github.com/apache/flink/pull/17256#discussion_r707338072



##########
File path: 
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CoalesceFunctionITCase.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.api.DataTypes;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+
+import org.junit.runners.Parameterized;
+
+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.INT;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.table.api.Expressions.call;
+import static org.apache.flink.table.api.Expressions.coalesce;
+
+/** Test COALESCE and its return type. * */
+public class CoalesceFunctionITCase extends BuiltInFunctionTestBase {
+
+    @Parameterized.Parameters(name = "{index}: {0}")
+    public static List<TestSpec> testData() {
+        return Arrays.asList(
+                TestSpec.forFunction(BuiltInFunctionDefinitions.COALESCE)
+                        .onFieldsWithData(null, null, 1)
+                        .andDataTypes(BIGINT().nullable(), INT().nullable(), 
INT().notNull())
+                        .testResult(
+                                coalesce($("f0"), $("f1")),
+                                "COALESCE(f0, f1)",
+                                null,
+                                DataTypes.BIGINT().nullable())
+                        .testResult(
+                                coalesce($("f0"), $("f2")),
+                                "COALESCE(f0, f2)",
+                                1L,
+                                DataTypes.BIGINT().notNull())
+                        .testResult(
+                                coalesce($("f1"), $("f2")),
+                                "COALESCE(f1, f2)",
+                                1,
+                                DataTypes.INT().notNull())
+                        .testResult(
+                                coalesce($("f0"), 1),
+                                "COALESCE(f0, 1)",
+                                1L,
+                                // In this case, the return type is not null 
because we have a
+                                // constant in the function invocation
+                                DataTypes.BIGINT().notNull())
+                        .testResult(

Review comment:
       This is to test the function works properly only with a single argument 




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


Reply via email to