You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/06/28 14:40:37 UTC
[doris] branch branch-1.2-lts updated: [1.2][fix](jdbc) Handling Zero DateTime Values in Non-nullable Columns for JDBC Catalog Reading MySQL (#21297)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new a0294ba161 [1.2][fix](jdbc) Handling Zero DateTime Values in Non-nullable Columns for JDBC Catalog Reading MySQL (#21297)
a0294ba161 is described below
commit a0294ba16168cac0cce16c1440d24011be8cf39d
Author: zy-kkk <zh...@gmail.com>
AuthorDate: Wed Jun 28 22:40:29 2023 +0800
[1.2][fix](jdbc) Handling Zero DateTime Values in Non-nullable Columns for JDBC Catalog Reading MySQL (#21297)
cherry-pick from #21296
---
.gitignore | 1 +
.../main/java/org/apache/doris/external/jdbc/JdbcClient.java | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/.gitignore b/.gitignore
index 2e1dc4d9af..a11163b2a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -93,3 +93,4 @@ tools/**/tpch-data/
# be-ut
data_test
+/ui/dist
\ No newline at end of file
diff --git a/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java b/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java
index 1d3c556b21..51a18c67d6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java
@@ -62,6 +62,8 @@ public class JdbcClient {
private boolean isLowerCaseTableNames = false;
+ private static boolean convertDateToNull = false;
+
// only used when isLowerCaseTableNames = true.
private Map<String, String> lowerTableToRealTable = Maps.newHashMap();
@@ -78,6 +80,7 @@ public class JdbcClient {
} catch (DdlException e) {
throw new JdbcClientException("Failed to parse db type from jdbcUrl: " + jdbcUrl, e);
}
+ convertDateToNull = isConvertDatetimeToNull(jdbcUrl);
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
try {
// TODO(ftw): The problem here is that the jar package is handled by FE
@@ -540,6 +543,9 @@ public class JdbcClient {
case "TIMESTAMP":
case "DATETIME":
case "DATETIMEV2": // for jdbc catalog connecting Doris database
+ if (convertDateToNull) {
+ fieldSchema.setAllowNull(true);
+ }
return ScalarType.getDefaultDateType(Type.DATETIME);
case "FLOAT":
return Type.FLOAT;
@@ -947,4 +953,9 @@ public class JdbcClient {
}
return dorisTableSchema;
}
+
+ private boolean isConvertDatetimeToNull(String JdbcUrl) {
+ // Check if the JDBC URL contains "zeroDateTimeBehavior=convertToNull".
+ return JdbcUrl.contains("zeroDateTimeBehavior=convertToNull");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org