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/14 11:36:00 UTC

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

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



##########
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),
+                            SqlTypeTransforms.LEAST_NULLABLE),

Review comment:
       Calcite's `TO_NULLABLE` actually has a (to me) surprising behavior that breaks tests: for structured types – like `ROW` – it also checks the nullability of all of the inner fields. This means that `ROW<r0 STRING> NOT NULL` would be considered nullable. Big "wat?" moment to me, and anxious to have someone explain to me why that makes sense.
   
   In any case, `LEAST_NULLABLE` does not have this behavior, and otherwise does the same thing in our case here.




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