From c68e6a9ca856ad441bbf311fa73814e583162182 Mon Sep 17 00:00:00 2001 From: ChinaYiGuan <91529181+ChinaYiGuan@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:49:35 +0800 Subject: [PATCH] [Fix](catalog) Doris datetime type conversion failed (#23906) 1. The catalog is connected to an old version of Doris, and an error is reported when using the datetime field type on the Doris surface . 2. error message [fe]: Caused by: java.lang.NumberFormatException: For input string: "DATETIM" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_291] at java.lang.Integer.parseInt(Integer.java:580) ~[?:1.8.0_291] at java.lang.Integer.parseInt(Integer.java:615) ~[?:1.8.0_291] at org.apache.doris.datasource.jdbc.client.JdbcMySQLClient.dorisTypeToDoris(JdbcMySQLClient.java:401) ~[doris-fe.jar:1.2- SNAPSHOT] --- .../apache/doris/datasource/jdbc/client/JdbcMySQLClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java index 7004309d2d..a58ac1a350 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java @@ -400,7 +400,8 @@ public class JdbcMySQLClient extends JdbcClient { return ScalarType.createDateV2Type(); case "DATETIME": case "DATETIMEV2": { - int scale = Integer.parseInt(upperType.substring(openParen + 1, upperType.length() - 1)); + int scale = (openParen == -1) ? 6 + : Integer.parseInt(upperType.substring(openParen + 1, upperType.length() - 1)); if (scale > 6) { scale = 6; }