You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/10/18 16:31:44 UTC

[GitHub] [flink] twalthr commented on a change in pull request #17481: [FLINK-24387][table-planner] Support JSON_STRING.

twalthr commented on a change in pull request #17481:
URL: https://github.com/apache/flink/pull/17481#discussion_r731112769



##########
File path: flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/expressions/converter/DirectConvertRule.java
##########
@@ -210,6 +210,10 @@
         DEFINITION_OPERATOR_MAP.put(
                 BuiltInFunctionDefinitions.STREAM_RECORD_TIMESTAMP,
                 FlinkSqlOperatorTable.STREAMRECORD_TIMESTAMP);
+
+        // JSON
+        DEFINITION_OPERATOR_MAP.put(

Review comment:
       in theory, we could use bridging function instead (for the planning) but with code gen for runtime implementation. is there a reason why we should have a Calcite function here?

##########
File path: flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/FlinkSqlOperatorTable.java
##########
@@ -1145,6 +1145,16 @@ public boolean isDeterministic() {
     public static final SqlFunction JSON_EXISTS = SqlStdOperatorTable.JSON_EXISTS;
     public static final SqlFunction JSON_VALUE = SqlStdOperatorTable.JSON_VALUE;
     public static final SqlFunction JSON_QUERY = SqlStdOperatorTable.JSON_QUERY;
+    public static final SqlFunction JSON_STRING =
+            new SqlFunction(
+                    "JSON_STRING",
+                    SqlKind.OTHER_FUNCTION,
+                    ReturnTypes.cascade(
+                            ReturnTypes.explicit(SqlTypeName.VARCHAR),

Review comment:
       side comment: let's overwrite the `VARCHAR(2000)` for the other JSON functions, it will cause issues in the future otherwise. we are discussing having it more strict in the future. see FLINK-24413.

##########
File path: flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/FlinkSqlOperatorTable.java
##########
@@ -1145,6 +1145,16 @@ public boolean isDeterministic() {
     public static final SqlFunction JSON_EXISTS = SqlStdOperatorTable.JSON_EXISTS;
     public static final SqlFunction JSON_VALUE = SqlStdOperatorTable.JSON_VALUE;
     public static final SqlFunction JSON_QUERY = SqlStdOperatorTable.JSON_QUERY;
+    public static final SqlFunction JSON_STRING =
+            new SqlFunction(
+                    "JSON_STRING",
+                    SqlKind.OTHER_FUNCTION,
+                    ReturnTypes.cascade(
+                            ReturnTypes.explicit(SqlTypeName.VARCHAR),
+                            FlinkReturnTypes.TO_NULLABLE_SHALLOW),

Review comment:
       This is known behavior. The inner nullability depends on the outer nullability.




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