You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/10/18 05:01:40 UTC

[GitHub] [incubator-seatunnel] 531651225 commented on a diff in pull request #3116: [Feature][Connector-V2] Kylin source connector

531651225 commented on code in PR #3116:
URL: https://github.com/apache/incubator-seatunnel/pull/3116#discussion_r997720125


##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/kylin/KylinTypeMapper.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.kylin;
+
+import org.apache.seatunnel.api.table.type.BasicType;
+import org.apache.seatunnel.api.table.type.DecimalType;
+import org.apache.seatunnel.api.table.type.LocalTimeType;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+
+public class KylinTypeMapper implements JdbcDialectTypeMapper {
+
+    private static final Logger LOG = LoggerFactory.getLogger(KylinTypeMapper.class);
+
+    // ============================data types=====================
+
+    private static final String KYLIN_UNKNOWN = "UNKNOWN";
+    private static final String KYLIN_BOOLEAN = "BOOLEAN";
+
+    // -------------------------number----------------------------
+    private static final String KYLIN_TINYINT = "TINYINT";
+    private static final String KYLIN_SMALLINT = "SMALLINT";
+    private static final String KYLIN_INT = "INT";
+    private static final String KYLIN_BIGINT = "BIGINT";
+    private static final String KYLIN_DECIMAL = "DECIMAL";
+    private static final String KYLIN_FLOAT = "FLOAT";
+    private static final String KYLIN_DOUBLE = "DOUBLE";
+
+    // -------------------------string----------------------------
+    private static final String KYLIN_CHAR = "CHAR";
+    private static final String KYLIN_VARCHAR = "VARCHAR";
+    private static final String KYLIN_STRING = "STRING";
+
+    // ------------------------------time-------------------------
+    private static final String KYLIN_DATE = "DATE";
+    private static final String KYLIN_TIME = "TIME";
+    private static final String KYLIN_TIMESTAMP = "TIMESTAMP";
+
+    @SuppressWarnings("checkstyle:MagicNumber")
+    @Override
+    public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex) throws SQLException {
+        String kylinType = metadata.getColumnTypeName(colIndex).toUpperCase();
+        int precision = metadata.getPrecision(colIndex);
+        int scale = metadata.getScale(colIndex);
+        switch (kylinType) {
+            case KYLIN_BOOLEAN:
+                return BasicType.BOOLEAN_TYPE;
+            case KYLIN_TINYINT:

Review Comment:
   > We have `short` type maybe you can use it to represent `tinyint`
   
   thinks your good advice,i have fixed it in new commit



-- 
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@seatunnel.apache.org

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