You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2023/01/03 12:34:27 UTC

[GitHub] [doris] morningman commented on a diff in pull request #15570: [feature](multi-catalog) support postgresql jdbc catalog

morningman commented on code in PR #15570:
URL: https://github.com/apache/doris/pull/15570#discussion_r1060541972


##########
fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java:
##########
@@ -371,11 +395,10 @@ public Type mysqlTypeToDoris(JdbcFieldSchema fieldSchema) {
             case "BIGINT":
                 return Type.BIGINT;
             case "DATE":
-                return ScalarType.getDefaultDateType(Type.DATE);
+                return Type.DATE;

Review Comment:
   Why not still using `ScalarType.getDefaultDateType`, so that we can control the behavior by FE config?



##########
fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java:
##########
@@ -418,7 +441,72 @@ public Type mysqlTypeToDoris(JdbcFieldSchema fieldSchema) {
                 return ScalarType.createStringType();
             default:
                 throw new JdbcClientException("Can not convert mysql data type to doris data type for type ["
-                                                + mysqlType + "]");
+                        + mysqlType + "]");
+        }
+    }
+
+    public Type postgresqlTypeToDoris(JdbcFieldSchema fieldSchema) {
+        String pgType = fieldSchema.getDataTypeName();
+        switch (pgType) {
+            case "int2":
+            case "smallserial":
+                return Type.SMALLINT;
+            case "int4":
+            case "serial":
+                return Type.INT;
+            case "int8":
+            case "bigserial":
+                return Type.BIGINT;
+            case "numeric": {
+                int precision = fieldSchema.getColumnSize() + 1;

Review Comment:
   Do we still need this `+1`? PG has no `unsigned` type.



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org