morningman commented on code in PR #15862: URL: https://github.com/apache/doris/pull/15862#discussion_r1068897375
########## fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java: ########## @@ -563,6 +563,65 @@ public Type clickhouseTypeToDoris(JdbcFieldSchema fieldSchema) { // Todo(zyk): Wait the JDBC external table support the array type then supported clickhouse array type } + public Type oracleTypeToDoris(JdbcFieldSchema fieldSchema) { + String oracleType = fieldSchema.getDataTypeName(); + if (oracleType.startsWith("INTERVAL")) { + oracleType = oracleType.substring(0, 8); + } + switch (oracleType) { + case "NUMBER": + int precision = fieldSchema.getColumnSize(); + int scale = fieldSchema.getDecimalDigits(); + if (scale == 0) { + if (precision < 3) { + return Type.TINYINT; + } else if (precision < 5) { + return Type.SMALLINT; + } else if (precision < 10) { + return Type.INT; + } else if (precision < 19) { + return Type.BIGINT; + } else if (precision < 39) { + return Type.LARGEINT; + } + return ScalarType.createStringType(); + } + if (precision <= ScalarType.MAX_DECIMAL128_PRECISION) { + if (!Config.enable_decimal_conversion && precision > ScalarType.MAX_DECIMALV2_PRECISION) { + return ScalarType.createStringType(); + } + return ScalarType.createDecimalType(precision, scale); + } else { + return ScalarType.createStringType(); + } + case "FLOAT": + return Type.DOUBLE; + case "VARCHAR2": + case "NVARCHAR2": + ScalarType varcharType = ScalarType.createVarcharType(fieldSchema.columnSize); + return varcharType; + case "CHAR": + case "NCHAR": + ScalarType charType = ScalarType.createCharType(fieldSchema.columnSize); Review Comment: Use String for all `char` and `varchar`, because the size of char/varchar in oracle maybe "char length", but in Doris, it is "byte length". For Chinese word, one Chinese word is 1 char length but 3 byte length. -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org