Repository: apache/flink
File: flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CollectionFunctionsITCase.java (Java)

Code before:
                        .testTableApiValidationError(
                                $("f4").split(","),
                                "Invalid input arguments. Expected signatures are:\n"
                                        + "SPLIT(<CHARACTER_STRING>, <CHARACTER_STRING>)")
                        .testSqlValidationError(
                                "SPLIT(f4, ',')",
                                "Invalid input arguments. Expected signatures are:\n"
                                        + "SPLIT(<CHARACTER_STRING>, <CHARACTER_STRING>)")
                        .testSqlValidationError(
                                "SPLIT()", "No match found for function signature SPLIT()")
                        .testSqlValidationError(
                                "SPLIT(f1, '1', '2')",
                                "No match found for function signature SPLIT(<CHARACTER>, <CHARACTER>, <CHARACTER>)"));
    }

    private Stream<TestSetSpec> arrayElementTestCases() {
        return Stream.of(
                TestSetSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_ELEMENT)
                        .onFieldsWithData(new Integer[] {1}, new Integer[] {1, 2})
                        .andDataTypes(
                                DataTypes.ARRAY(DataTypes.INT()), DataTypes.ARRAY(DataTypes.INT()))
                        .testResult($("f0").element(), "ELEMENT(f0)", 1, DataTypes.INT())
                        .testSqlRuntimeError(
                                "ELEMENT(f1)",
                                TableRuntimeException.class,
                                "Array has more than one element."));
    }
}


Review comment (refactor):
great, 
one last comment: can we move all the tests for `element` function from `ArrayTypeTest#testArrayOperations` here?

It would simplify future code navigation

Code after:
                        .testTableApiValidationError(
                                $("f4").split(","),
                                "Invalid input arguments. Expected signatures are:\n"
                                        + "SPLIT(<CHARACTER_STRING>, <CHARACTER_STRING>)")
                        .testSqlValidationError(
                                "SPLIT(f4, ',')",
                                "Invalid input arguments. Expected signatures are:\n"
                                        + "SPLIT(<CHARACTER_STRING>, <CHARACTER_STRING>)")
                        .testSqlValidationError(
                                "SPLIT()", "No match found for function signature SPLIT()")
                        .testSqlValidationError(
                                "SPLIT(f1, '1', '2')",
                                "No match found for function signature SPLIT(<CHARACTER>, <CHARACTER>, <CHARACTER>)"));
    }

    private Stream<TestSetSpec> arrayElementTestCases() {
        return Stream.of(
                TestSetSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_ELEMENT)
                        .onFieldsWithData(
                                new Integer[] {1}, new Integer[] {1, 2}, new float[] {4.0F}, null)
                        .andDataTypes(
                                DataTypes.ARRAY(DataTypes.INT()),
                                DataTypes.ARRAY(DataTypes.INT()),
                                DataTypes.ARRAY(DataTypes.FLOAT()),
                                DataTypes.ARRAY(DataTypes.INT()))
                        .testResult($("f0").element(), "ELEMENT(f0)", 1, DataTypes.INT())
                        .testSqlRuntimeError(
                                "ELEMENT(f1)",
                                TableRuntimeException.class,
                                "Array has more than one element.")
                        .testResult($("f2").element(), "ELEMENT(f2)", 4.0F, DataTypes.FLOAT())
                        .testResult($("f3").element(), "ELEMENT(f3)", null, DataTypes.INT()));
    }
}