twalthr commented on code in PR #26767:
URL: https://github.com/apache/flink/pull/26767#discussion_r2192357017


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MiscFunctionsITCase.java:
##########
@@ -205,7 +206,50 @@ Stream<TestSetSpec> getTestSetSpecs() {
                         .testTableApiResult(
                                 call(OptionalArgAtEndFunction.class, $("f0")),
                                 "i=12,optional=null",
-                                DataTypes.STRING()));
+                                DataTypes.STRING()),
+                TestSetSpec.forFunction(BuiltInFunctionDefinitions.ENCODE)
+                        .onFieldsWithData(null, "Hello world", "utf-8")
+                        .andDataTypes(
+                                DataTypes.STRING().nullable(),
+                                DataTypes.STRING(),
+                                DataTypes.STRING())
+                        .testResult(
+                                $("f0").encode($("f2")),
+                                "ENCODE(f0, f2)",
+                                null,
+                                DataTypes.BYTES().nullable())
+                        .testResult(
+                                $("f1").encode($("f2")),
+                                "ENCODE(f1, f2)",
+                                "Hello world".getBytes(StandardCharsets.UTF_8),
+                                DataTypes.BYTES().nullable())
+                        .testResult(
+                                // test for static values

Review Comment:
   ```suggestion
                                   // test for literal values
   ```



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MiscFunctionsITCase.java:
##########
@@ -235,4 +279,15 @@ public String eval(int i, @ArgumentHint(isOptional = true) 
String optional) {
             return String.format("i=%s,optional=%s", i, optional);
         }
     }
+
+    private static String toHexString(String input) {

Review Comment:
   use org.apache.flink.table.utils.EncodingUtils#hex(java.lang.String)



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MiscFunctionsITCase.java:
##########
@@ -205,7 +206,50 @@ Stream<TestSetSpec> getTestSetSpecs() {
                         .testTableApiResult(
                                 call(OptionalArgAtEndFunction.class, $("f0")),
                                 "i=12,optional=null",
-                                DataTypes.STRING()));
+                                DataTypes.STRING()),
+                TestSetSpec.forFunction(BuiltInFunctionDefinitions.ENCODE)
+                        .onFieldsWithData(null, "Hello world", "utf-8")
+                        .andDataTypes(
+                                DataTypes.STRING().nullable(),
+                                DataTypes.STRING(),
+                                DataTypes.STRING())
+                        .testResult(
+                                $("f0").encode($("f2")),
+                                "ENCODE(f0, f2)",
+                                null,
+                                DataTypes.BYTES().nullable())
+                        .testResult(
+                                $("f1").encode($("f2")),
+                                "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

Review Comment:
   ```suggestion
                                   // test for literal values
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to