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 2022/02/21 08:29:23 UTC

[GitHub] [flink] twalthr commented on a change in pull request #18524: [FLINK-25428][table-common][table-planner] Expose string casting for map, multiset, structured, row and raw

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



##########
File path: flink-core/src/main/java/org/apache/flink/util/CollectionUtil.java
##########
@@ -109,4 +110,22 @@ public static boolean isNullOrEmpty(Map<?, ?> map) {
         iterator.forEachRemaining(list::add);
         return list;
     }
+
+    /** Returns an immutable {@link Map.Entry}. */
+    public static <K, V> Map.Entry<K, V> entry(K k, V v) {

Review comment:
       please put core changes in a hotfix commit

##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeCasts.java
##########
@@ -318,11 +318,17 @@ private static boolean supportsCasting(
             // cast between interval and exact numeric is only supported if interval has a single
             // field
             return isSingleFieldInterval(targetType);
+        } else if ((sourceType.is(CONSTRUCTED) || sourceType.is(STRUCTURED_TYPE))
+                && targetType.is(CHARACTER_STRING)) {
+            return supportsCollectionAndStructuredToStringCasting(sourceType, allowExplicit);

Review comment:
       can't this also just always be `true`? What casting does not support to string?

##########
File path: flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
##########
@@ -0,0 +1,220 @@
+/*
+ * 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.calcite.sql.fun;
+
+import org.apache.flink.table.planner.calcite.FlinkTypeFactory;
+import org.apache.flink.table.types.logical.utils.LogicalTypeCasts;
+
+import com.google.common.collect.ImmutableSetMultimap;
+import com.google.common.collect.SetMultimap;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFamily;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlDynamicParam;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlIntervalQualifier;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperandCountRange;
+import org.apache.calcite.sql.SqlOperatorBinding;
+import org.apache.calcite.sql.SqlSyntax;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.type.InferTypes;
+import org.apache.calcite.sql.type.SqlOperandCountRanges;
+import org.apache.calcite.sql.type.SqlTypeFamily;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.apache.calcite.sql.validate.SqlMonotonicity;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
+
+import java.text.Collator;
+import java.util.Objects;
+
+import static org.apache.calcite.util.Static.RESOURCE;
+
+/**
+ * SqlCastFunction. Note that the std functions are really singleton objects, because they always
+ * get fetched via the StdOperatorTable. So you can't store any local info in the class and hence
+ * the return type data is maintained in operand[1] through the validation phase.
+ *
+ * <p>Can be used for both {@link SqlCall} and {@link org.apache.calcite.rex.RexCall}. Note that the
+ * {@code SqlCall} has two operands (expression and type), while the {@code RexCall} has one operand
+ * (expression) and the type is obtained from {@link org.apache.calcite.rex.RexNode#getType()}.
+ *
+ * <p>The class was copied over because of CALCITE-XXXX, in order to workaround the method {@link

Review comment:
       `CALCITE-XXXX`?




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