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

commit 9a51fc761efa464ec70dbf4853e74269d56c1ca1
Author: Ashin Gau <[email protected]>
AuthorDate: Tue May 9 13:53:17 2023 +0800

    [fix](JDBC) set jdbc parameters to compatible with both MySQL and Doris 
when reading boolean type (#19399)
    
    Fix errors when read boolean type from external doris cluster by jdbc 
catalog:
    ```
    ERROR 1105 (HY000): errCode = 2, detailMessage = 
(172.16.10.11)[INTERNAL_ERROR]Fail to convert jdbc type of java.lang.Integer to 
doris type BOOL on column: deleted.
    You need to check this column type between external table and doris table.
    ```
    MySQL Types and Return Values for GetColumnTypeName and GetColumnClassName 
are presented in 
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html.
    However when tinyInt1isBit=false, GetColumnClassName of MySQL returns 
java.lang.Boolean, while that of Doris returns java.lang.Integer. In order to 
be compatible with both MySQL and Doris, Jdbc params should set 
tinyInt1isBit=true&transformedBitIsBoolean=true
---
 .../src/main/java/org/apache/doris/catalog/JdbcResource.java  | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcResource.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcResource.java
index ad7d8dc0fd..ed09ff5861 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcResource.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcResource.java
@@ -279,10 +279,13 @@ public class JdbcResource extends Resource {
             // `yearIsDateType` is a parameter of JDBC, and the default is 
true.
             // We force the use of `yearIsDateType=false`
             newJdbcUrl = checkAndSetJdbcBoolParam(newJdbcUrl, 
"yearIsDateType", "true", "false");
-            // `tinyInt1isBit` is a parameter of JDBC, and the default is true.
-            // We force the use of `tinyInt1isBit=false`, so that for mysql 
type tinyint,
-            // it will convert to Doris tinyint, not bit.
-            newJdbcUrl = checkAndSetJdbcBoolParam(newJdbcUrl, "tinyInt1isBit", 
"true", "false");
+            // MySQL Types and Return Values for GetColumnTypeName and 
GetColumnClassName
+            // are presented in 
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html
+            // However when tinyInt1isBit=false, GetColumnClassName of MySQL 
returns java.lang.Boolean,
+            // while that of Doris returns java.lang.Integer. In order to be 
compatible with both MySQL and Doris,
+            // Jdbc params should set 
tinyInt1isBit=true&transformedBitIsBoolean=true
+            newJdbcUrl = checkAndSetJdbcBoolParam(newJdbcUrl, "tinyInt1isBit", 
"true", "true");
+            newJdbcUrl = checkAndSetJdbcBoolParam(newJdbcUrl, 
"transformedBitIsBoolean", "true", "true");
             // set useUnicode and characterEncoding to false and utf-8
             newJdbcUrl = checkAndSetJdbcBoolParam(newJdbcUrl, "useUnicode", 
"false", "true");
             newJdbcUrl = checkAndSetJdbcParam(newJdbcUrl, "characterEncoding", 
"utf-8");


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

Reply via email to