luoyuxia commented on code in PR #22620:
URL: https://github.com/apache/flink/pull/22620#discussion_r1236462964


##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/planner/utils/FlinkTypeUtils.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.utils;
+
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.catalog.ResolvedSchema;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.ArrayType;
+import org.apache.flink.table.types.logical.BigIntType;
+import org.apache.flink.table.types.logical.BinaryType;
+import org.apache.flink.table.types.logical.BooleanType;
+import org.apache.flink.table.types.logical.CharType;
+import org.apache.flink.table.types.logical.DateType;
+import org.apache.flink.table.types.logical.DecimalType;
+import org.apache.flink.table.types.logical.DoubleType;
+import org.apache.flink.table.types.logical.FloatType;
+import org.apache.flink.table.types.logical.IntType;
+import org.apache.flink.table.types.logical.LocalZonedTimestampType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.MapType;
+import org.apache.flink.table.types.logical.MultisetType;
+import org.apache.flink.table.types.logical.NullType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.types.logical.SmallIntType;
+import org.apache.flink.table.types.logical.SymbolType;
+import org.apache.flink.table.types.logical.TimeType;
+import org.apache.flink.table.types.logical.TimestampType;
+import org.apache.flink.table.types.logical.TinyIntType;
+import org.apache.flink.table.types.logical.VarBinaryType;
+import org.apache.flink.table.types.logical.VarCharType;
+import org.apache.flink.table.types.utils.TypeConversions;
+import org.apache.flink.util.Preconditions;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import static org.apache.calcite.sql.type.SqlTypeName.DAY_INTERVAL_TYPES;
+import static org.apache.calcite.sql.type.SqlTypeName.YEAR_INTERVAL_TYPES;
+
+/** Utils for Mapping Calcite's type to Flink's type, most code is copied from 
FlinkTypeFactory. */
+public class FlinkTypeUtils {
+
+    public static ResolvedSchema resolvedSchema(RelNode calciteTree) {
+        RelDataType rowType = calciteTree.getRowType();
+        String[] fieldNames = rowType.getFieldNames().toArray(new String[0]);
+
+        DataType[] fieldTypes =
+                rowType.getFieldList().stream()
+                        .map(
+                                field ->
+                                        TypeConversions.fromLogicalToDataType(
+                                                
toLogicalType(field.getType())))
+                        .toArray(DataType[]::new);
+
+        return ResolvedSchema.physical(fieldNames, fieldTypes);
+    }
+
+    public static Class<?> getConversionClass(RelDataType relDataType) {
+        // just use default conversion class
+        return toLogicalType(relDataType).getDefaultConversion();
+    }
+
+    public static LogicalType toLogicalType(RelDataType relDataType) {

Review Comment:
   Miss it while doing the copy & paste. I'll fix it as well as add test 



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