This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 5ffd5e00a3f [bugfix](clickhouse) fix datetime convert error. (#26128) 
(#26766)
5ffd5e00a3f is described below

commit 5ffd5e00a3f35a14e88d936d15fcc84a355b5020
Author: Mingyu Chen <[email protected]>
AuthorDate: Sat Nov 11 15:21:51 2023 +0800

    [bugfix](clickhouse) fix datetime convert error. (#26128) (#26766)
    
    Co-authored-by: Guangdong Liu <[email protected]>
---
 .../doris/datasource/jdbc/client/JdbcClickHouseClient.java  | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClickHouseClient.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClickHouseClient.java
index 292dea760ef..b68ec481d3d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClickHouseClient.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClickHouseClient.java
@@ -58,25 +58,26 @@ public class JdbcClickHouseClient extends JdbcClient {
             return createDecimalOrStringType(precision, scale);
         }
 
-        if ("String".contains(ckType) || ckType.startsWith("Enum")
-                || ckType.startsWith("IPv") || "UUID".contains(ckType)
+        if ("String".contains(ckType)
+                || ckType.startsWith("Enum")
+                || ckType.startsWith("IPv")
+                || "UUID".contains(ckType)
                 || ckType.startsWith("FixedString")) {
             return ScalarType.createStringType();
         }
 
         if (ckType.startsWith("DateTime")) {
             // DateTime with second precision
-            if (ckType.equals("DateTime")) {
+            if (ckType.startsWith("DateTime(") || ckType.equals("DateTime")) {
                 return ScalarType.createDatetimeV2Type(0);
             } else {
-                // DateTime64 with [0~9] precision
                 int indexStart = ckType.indexOf('(');
                 int indexEnd = ckType.indexOf(')');
                 if (indexStart != -1 && indexEnd != -1) {
                     String scaleStr = ckType.substring(indexStart + 1, 
indexEnd);
                     int scale = Integer.parseInt(scaleStr);
-                    if (scale > 6) {
-                        scale = 6;
+                    if (scale > JDBC_DATETIME_SCALE) {
+                        scale = JDBC_DATETIME_SCALE;
                     }
                     // return with the actual scale
                     return ScalarType.createDatetimeV2Type(scale);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to