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

Code before:
                                "ENCODE(f1, f2)",
                                "Hello world".getBytes(StandardCharsets.UTF_8),
                                DataTypes.BYTES().nullable())
                        .testResult(
                                // test for static values
                                lit("Hello world").encode($("f2")),
                                "ENCODE('Hello world', f2)",
                                "Hello world".getBytes(StandardCharsets.UTF_8),
                                DataTypes.BYTES().nullable()),
                TestSetSpec.forFunction(BuiltInFunctionDefinitions.DECODE)
                        .onFieldsWithData(
                                null, "Hello world".getBytes(StandardCharsets.UTF_8), "utf-8")
                        .andDataTypes(
                                DataTypes.BYTES().nullable(), DataTypes.BYTES(), DataTypes.STRING())
                        .testResult(
                                $("f0").decode($("f2")),
                                "DECODE(f0, f2)",
                                null,
                                DataTypes.STRING().nullable())
                        .testResult(
                                $("f1").decode($("f2")),
                                "DECODE(f1, f2)",
                                "Hello world",
                                DataTypes.STRING().nullable())
                        .testResult(
                                // test for static values
                                lit("Hello world".getBytes(StandardCharsets.UTF_8)).decode($("f2")),
                                "DECODE(" + toHexString("Hello world") + ", f2)",
                                "Hello world",
                                DataTypes.STRING().nullable()));
    }

    // --------------------------------------------------------------------------------------------

    /** Function that takes a NOT NULL argument. */
    public static class TakesNotNull extends ScalarFunction {
        public int eval(int i) {
            return i;
        }
    }

    /** Function that uses a static signature. */
    public static class OptionalArgInMiddleFunction extends ScalarFunction {
        public String eval(
                int i,
                @ArgumentHint(isOptional = true) String optional,
                Long l,
                Boolean b,
                String s) {
            return String.format("i=%s,optional=%s,l=%s,b=%s,s=%s", i, optional, l, b, s);
        }

Review comment (suggestion):
```suggestion
                                // test for literal values
```

Code after:
                                $("f1").encode($("f2")),
                                "ENCODE(f1, f2)",
                                "Hello world".getBytes(StandardCharsets.UTF_8),
                                DataTypes.BYTES().nullable())
                        .testResult(
                                // test for literal values
                                lit("Hello world").encode($("f2")),
                                "ENCODE('Hello world', f2)",
                                "Hello world".getBytes(StandardCharsets.UTF_8),
                                DataTypes.BYTES().nullable()),
                TestSetSpec.forFunction(BuiltInFunctionDefinitions.DECODE)
                        .onFieldsWithData(
                                null, "Hello world".getBytes(StandardCharsets.UTF_8), "utf-8")
                        .andDataTypes(
                                DataTypes.BYTES().nullable(), DataTypes.BYTES(), DataTypes.STRING())
                        .testResult(
                                $("f0").decode($("f2")),
                                "DECODE(f0, f2)",
                                null,
                                DataTypes.STRING().nullable())
                        .testResult(
                                $("f1").decode($("f2")),
                                "DECODE(f1, f2)",
                                "Hello world",
                                DataTypes.STRING().nullable())
                        .testResult(
                                // test for literal values
                                lit("Hello world".getBytes(StandardCharsets.UTF_8)).decode($("f2")),
                                "DECODE(x'" + EncodingUtils.hex("Hello world") + "', f2)",
                                "Hello world",
                                DataTypes.STRING().nullable()));
    }

    // --------------------------------------------------------------------------------------------

    /** Function that takes a NOT NULL argument. */
    public static class TakesNotNull extends ScalarFunction {
        public int eval(int i) {
            return i;
        }
    }

    /** Function that uses a static signature. */
    public static class OptionalArgInMiddleFunction extends ScalarFunction {
        public String eval(
                int i,
                @ArgumentHint(isOptional = true) String optional,
                Long l,
                Boolean b,
                String s) {
            return String.format("i=%s,optional=%s,l=%s,b=%s,s=%s", i, optional, l, b, s);