You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/12/24 05:58:11 UTC

[GitHub] [incubator-kyuubi] hddong commented on a change in pull request #1617: [KYUUBI #1581] Add SchemaHelper for trino engine

hddong commented on a change in pull request #1617:
URL: https://github.com/apache/incubator-kyuubi/pull/1617#discussion_r774885993



##########
File path: externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/schema/SchemaHelper.scala
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.kyuubi.engine.trino.schema
+
+import java.util.Collections
+import java.util.Locale
+
+import scala.collection.JavaConverters._
+
+import io.trino.client.ClientStandardTypes._
+import io.trino.client.ClientTypeSignature
+import io.trino.client.Column
+import org.apache.hive.service.rpc.thrift.TCLIServiceConstants
+import org.apache.hive.service.rpc.thrift.TColumnDesc
+import org.apache.hive.service.rpc.thrift.TPrimitiveTypeEntry
+import org.apache.hive.service.rpc.thrift.TTableSchema
+import org.apache.hive.service.rpc.thrift.TTypeDesc
+import org.apache.hive.service.rpc.thrift.TTypeEntry
+import org.apache.hive.service.rpc.thrift.TTypeId
+import org.apache.hive.service.rpc.thrift.TTypeQualifiers
+import org.apache.hive.service.rpc.thrift.TTypeQualifierValue
+
+object SchemaHelper {
+
+  def toTTypeId(typ: ClientTypeSignature): TTypeId = typ.getRawType.toLowerCase(Locale.ROOT) match {
+    case BOOLEAN => TTypeId.BOOLEAN_TYPE
+    case TINYINT => TTypeId.TINYINT_TYPE
+    case SMALLINT => TTypeId.SMALLINT_TYPE
+    case INTEGER => TTypeId.INT_TYPE
+    case BIGINT => TTypeId.BIGINT_TYPE
+    case REAL => TTypeId.FLOAT_TYPE
+    case DOUBLE => TTypeId.DOUBLE_TYPE
+    case DECIMAL => TTypeId.DECIMAL_TYPE
+    case CHAR => TTypeId.CHAR_TYPE
+    case VARCHAR => TTypeId.VARCHAR_TYPE
+    case VARBINARY => TTypeId.BINARY_TYPE
+    case DATE => TTypeId.DATE_TYPE
+    case TIMESTAMP => TTypeId.TIMESTAMP_TYPE
+    case INTERVAL_DAY_TO_SECOND => TTypeId.INTERVAL_DAY_TIME_TYPE
+    case INTERVAL_YEAR_TO_MONTH => TTypeId.INTERVAL_YEAR_MONTH_TYPE
+    case ARRAY => TTypeId.ARRAY_TYPE
+    case MAP => TTypeId.MAP_TYPE
+    case ROW => TTypeId.STRUCT_TYPE
+    case _ => TTypeId.STRING_TYPE

Review comment:
       Done.




-- 
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: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org