You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "snuyanzin (via GitHub)" <gi...@apache.org> on 2025/07/08 11:00:24 UTC

[PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

snuyanzin opened a new pull request, #26767:
URL: https://github.com/apache/flink/pull/26767

   ## What is the purpose of the change
   
   The PR fixes the behavior of `ENCODE` as mentioned in jira issue
   
   ## Brief change log
   
   
   
   ## Verifying this change
   
   The test added under MiscFunctionsITCase.java
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): ( no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: ( no)
     - The serializers: ( no)
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: ( no )
     - The S3 file system connector: (yes)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? ( no)
     - If yes, how is the feature documented? (not applicable )
   


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #26767:
URL: https://github.com/apache/flink/pull/26767#issuecomment-3048933000

   >Should we remove nullableIfArgs in BuiltInFunctionDefinitions#ENCODE? Same for DECODE.
   
   why ?
   ```sql
   SELECT encode(cast(null as string), 'utf-8'), encode(cast(null as string), cast(null as string)), encode('asd', cast(null as string));
   ```
   returns
   ```
   null, null, null
   ```
   or did I miss anything?


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #26767:
URL: https://github.com/apache/flink/pull/26767#issuecomment-3048904656

   Should we remove `nullableIfArgs` in `BuiltInFunctionDefinitions#ENCODE`? Same for `DECODE`.


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #26767:
URL: https://github.com/apache/flink/pull/26767


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #26767:
URL: https://github.com/apache/flink/pull/26767#issuecomment-3048433939

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b511178fbbaf952194fa2b02e1b5af06b3e019f5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b511178fbbaf952194fa2b02e1b5af06b3e019f5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b511178fbbaf952194fa2b02e1b5af06b3e019f5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "twalthr (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #26767:
URL: https://github.com/apache/flink/pull/26767#issuecomment-3049045189

   > can you log an issue for that with description and a test case then?
   > We can continue discussion there and fix if required
   
   OK. And this pr LGTM.


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #26767:
URL: https://github.com/apache/flink/pull/26767#issuecomment-3048962901

   > >Should we remove nullableIfArgs in BuiltInFunctionDefinitions#ENCODE? Same for DECODE.
   > 
   > why ?
   > ```sql
   > SELECT encode(cast(null as string), 'utf-8'), encode(cast(null as string), cast(null as string)), encode('asd', cast(null as string));
   > ```
   > returns
   > ```
   > null, null, null
   > ```
   > or did I miss anything?
   
   I mean the nullability of return types are different in  `BuiltInFunctionDefinitions` and `FlinkSqlOperatorTable` ?


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38062][table] `ENCODE` function behaves wrong [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #26767:
URL: https://github.com/apache/flink/pull/26767#issuecomment-3049020735

   can you log an issue for that with description and a test case then?
   We can continue discussion there and fix if required


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org