slinkydeveloper commented on a change in pull request #17691:
URL: https://github.com/apache/flink/pull/17691#discussion_r746367712



##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/SqlJsonArrayFunctionWrapper.java
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.functions.sql;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlOperatorBinding;
+import org.apache.calcite.sql.fun.SqlJsonArrayFunction;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+
+import static 
org.apache.flink.table.planner.plan.type.FlinkReturnTypes.VARCHAR_NOT_NULLABLE;
+
+/**
+ * This class is a wrapper class for the {@link SqlJsonArrayFunction} with the 
return type STRING.

Review comment:
       I would modify it to:
   
   ```
   This class is a wrapper class for the {@link SqlJsonArrayFunction} but using 
the {@link VARCHAR_NOT_NULLABLE} retun type inference.
   ```

##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/SqlJsonQueryFunctionWrapper.java
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.functions.sql;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlOperatorBinding;
+import org.apache.calcite.sql.fun.SqlJsonQueryFunction;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+
+import static 
org.apache.flink.table.planner.plan.type.FlinkReturnTypes.VARCHAR_FORCE_NULLABLE;
+
+/**
+ * This class is a wrapper class for the {@link SqlJsonQueryFunction} with the 
return type STRING.

Review comment:
       Same as above

##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/type/FlinkReturnTypes.java
##########
@@ -104,9 +104,13 @@ public RelDataType inferReturnType(SqlOperatorBinding 
opBinding) {
                 }
             };
 
-    /** Type-inference strategy that always returns "VARCHAR(2000)" with nulls 
always allowed. */
-    public static final SqlReturnTypeInference VARCHAR_2000_NULLABLE =
-            ReturnTypes.cascade(ReturnTypes.VARCHAR_2000, 
SqlTypeTransforms.FORCE_NULLABLE);
+    public static final SqlReturnTypeInference VARCHAR_FORCE_NULLABLE =
+            ReturnTypes.cascade(
+                    ReturnTypes.explicit(SqlTypeName.VARCHAR), 
SqlTypeTransforms.FORCE_NULLABLE);
+
+    public static final SqlReturnTypeInference VARCHAR_NOT_NULLABLE =

Review comment:
       Rename to `VARCHAR_NOT_NULL`, which is the terminology we use in other 
parts of the code base, also because it's less confusing.

##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/SqlJsonObjectFunction.java
##########
@@ -42,19 +40,18 @@
 import java.util.Locale;
 
 import static org.apache.calcite.util.Static.RESOURCE;
+import static 
org.apache.flink.table.planner.plan.type.FlinkReturnTypes.VARCHAR_NOT_NULLABLE;
 
 /**
- * This class has been copied from Calcite to backport the fix made during 
CALCITE-4394.
- *
- * <p>TODO Remove this class with Calcite 1.27 and replace it with {@link

Review comment:
       Perhaps keep this todo, so once we update to calcite 1.27 we can just 
create a wrapper like you did for `JSON_QUERY` and `JSON_ARRAY`




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