slinkydeveloper commented on a change in pull request #17691:
URL: https://github.com/apache/flink/pull/17691#discussion_r744708841
##########
File path:
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/type/FlinkReturnTypes.java
##########
@@ -104,9 +104,9 @@ 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_NULLABLE =
Review comment:
Perhaps name it `VARCHAR_FORCE_NULLABLE` to make more explicit the
nullability behaviour?
##########
File path:
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/SqlJsonQueryFunction.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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.sql.SqlCall;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlJsonQueryEmptyOrErrorBehavior;
+import org.apache.calcite.sql.SqlJsonQueryWrapperBehavior;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlTypeFamily;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeTransforms;
+
+/** This class has been copied from Calcite to replace the return type
VARCHAR(2000) with STRING. */
Review comment:
I wonder if you can just create a wrapper for `SqlFunction` to avoid
copy-pasting `SqlJsonQueryFunction` and `SqlJsonArrayFunction`. If you check
the code for `SqlFunction`, you see that the return type inference is used only
for:
* `SqlReturnTypeInference getReturnTypeInference()` which is just a getter
* `RelDataType inferReturnType(SqlOperatorBinding opBinding)` which is a
wrapper call for SqlReturnTypeInference.inferReturnType`.
WDYT?
--
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]