This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new bd74890cf7 [fix](multi-catalog) JDBC Catalog Unknown UNSIGNED type of
mysql, type: [DOUBLE] (#19912)
bd74890cf7 is described below
commit bd74890cf7617b0e87a3d1d68510e5e9715026e5
Author: Ashin Gau <[email protected]>
AuthorDate: Tue May 23 09:29:57 2023 +0800
[fix](multi-catalog) JDBC Catalog Unknown UNSIGNED type of mysql, type:
[DOUBLE] (#19912)
---
.../docker-compose/mysql/init/03-create-table.sql | 35 ++++++++++++++++++++++
.../docker-compose/mysql/init/04-insert.sql | 14 +++++++++
.../org/apache/doris/external/jdbc/JdbcClient.java | 8 +++++
.../jdbc_catalog_p0/test_mysql_jdbc_catalog.out | 5 ++++
.../jdbc_catalog_p0/test_mysql_jdbc_catalog.groovy | 5 ++++
5 files changed, 67 insertions(+)
diff --git a/docker/thirdparties/docker-compose/mysql/init/03-create-table.sql
b/docker/thirdparties/docker-compose/mysql/init/03-create-table.sql
index e6e03a8e0b..829d9a88c4 100644
--- a/docker/thirdparties/docker-compose/mysql/init/03-create-table.sql
+++ b/docker/thirdparties/docker-compose/mysql/init/03-create-table.sql
@@ -248,3 +248,38 @@ create table doris_test.test_insert2 (
k14 datetime,
k15 timestamp
) engine=innodb charset=utf8;
+
+create table doris_test.all_types (
+ `tinyint_u` tinyint unsigned,
+ `smallint_u` smallint unsigned,
+ `mediumint_u` mediumint unsigned,
+ `int_u` int unsigned,
+ `bigint_u` bigint unsigned,
+ `decimal_u` decimal(18, 5) unsigned,
+ `double_u` double unsigned,
+ `float_u` float unsigned,
+ `boolean` boolean,
+ `tinyint` tinyint,
+ `smallint` smallint,
+ `year` year,
+ `mediumint` mediumint,
+ `int` int,
+ `bigint` bigint,
+ `date` date,
+ `timestamp` timestamp(4),
+ `datetime` datetime,
+ `float` float,
+ `double` double,
+ `decimal` decimal(12, 4),
+ `char` char(5),
+ `varchar` varchar(10),
+ `time` time(4),
+ `text` text,
+ `blob` blob,
+ `json` json,
+ `set` set('Option1', 'Option2', 'Option3'),
+ `bit` bit(6),
+ `binary` binary(12),
+ `varbinary` varbinary(12),
+ `enum` enum('Value1', 'Value2', 'Value3')
+) engine=innodb charset=utf8;
diff --git a/docker/thirdparties/docker-compose/mysql/init/04-insert.sql
b/docker/thirdparties/docker-compose/mysql/init/04-insert.sql
index c65345c537..35a322134c 100644
--- a/docker/thirdparties/docker-compose/mysql/init/04-insert.sql
+++ b/docker/thirdparties/docker-compose/mysql/init/04-insert.sql
@@ -1124,3 +1124,17 @@ INSERT INTO doris_test.ex_tb20 VALUES
(1.12345, 1.12345, 1.12345, 1.12345, 1.12345, 1.12345),
(123456789012345678901234567890123.12345,
12345678901234567890123456789012.12345,
1234567890123456789012345678901234.12345,
123456789012345678901234567890123.12345,
123456789012345678901234567890123456789012345678901234567890.12345,
123456789012345678901234567890123456789012345678901234567890.12345);
+
+INSERT INTO doris_test.all_types VALUES
+(201, 301, 401, 501, 601, 3.14159, 4.1415926, 5.141592, true, -123, -301,
2012, -401, -501, -601, '2012-10-30', '2012-10-25 12:05:36.3456712',
'2012-10-25 08:08:08.3456712',
+ -4.14145001, -5.1400000001, -6.140000001, 'row1', 'line1',
'09:09:09.56782346', 'text1', X'48656C6C6F20576F726C64', '{"name": "Alice",
"age": 30, "city": "London"}',
+ 'Option1,Option3', b'101010', X'48656C6C6F', X'48656C6C6F', 'Value2'),
+(202, 302, 402, 502, 602, 4.14159, 5.1415926, 6.141592, false, -124, -302,
2013, -402, -502, -602, '2012-11-01', '2012-10-26 02:08:39.3456712',
'2013-10-26 08:09:18.3456712',
+ -5.14145001, -6.1400000001, -7.140000001, 'row2', 'line2',
'09:11:09.56782346', 'text2', X'E86F6C6C6F20576F726C67', '{"name": "Gaoxin",
"age": 18, "city": "ChongQing"}',
+ 'Option1,Option2', b'101111', X'58676C6C6F', X'88656C6C9F', 'Value3'),
+(null, 302, null, 502, 602, 4.14159, null, 6.141592, null, -124, -302, 2013,
-402, -502, -602, null, '2012-10-26 02:08:39.3456712', '2013-10-26
08:09:18.3456712',
+ -5.14145001, null, -7.140000001, 'row2', null, '09:11:09.56782346', 'text2',
X'E86F6C6C6F20576F726C67', null,
+ null, b'101111', null, X'88656C6C9F', 'Value3'),
+(203, 303, 403, 503, 603, 7.14159, 8.1415926, 9.141592, false, null, -402,
2017, -602, -902, -1102, '2012-11-02', null, '2013-10-27 08:11:18.3456712',
+ -5.14145000001, -6.1400000000001, -7.140000000001, 'row3', 'line3',
'09:11:09.56782346', 'text3', X'E86F6C6C6F20576F726C67', '{"name": "ChenQi",
"age": 24, "city": "ChongQing"}',
+ 'Option2', b'101111', X'58676C6C6F', null, 'Value1');
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 816df17856..c6ef02cb28 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
@@ -523,6 +523,14 @@ public class JdbcClient {
int precision = fieldSchema.getColumnSize() + 1;
int scale = fieldSchema.getDecimalDigits();
return createDecimalOrStringType(precision, scale);
+ case "DOUBLE":
+ // As of MySQL 8.0.17, the UNSIGNED attribute is deprecated
+ // for columns of type FLOAT, DOUBLE, and DECIMAL (and any
synonyms)
+ //
https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
+ // The maximum value may cause errors due to insufficient
accuracy
+ return Type.DOUBLE;
+ case "FLOAT":
+ return Type.FLOAT;
default:
throw new JdbcClientException("Unknown UNSIGNED type of
mysql, type: [" + mysqlType + "]");
}
diff --git a/regression-test/data/jdbc_catalog_p0/test_mysql_jdbc_catalog.out
b/regression-test/data/jdbc_catalog_p0/test_mysql_jdbc_catalog.out
index 29f1b41dc2..62fb42f033 100644
--- a/regression-test/data/jdbc_catalog_p0/test_mysql_jdbc_catalog.out
+++ b/regression-test/data/jdbc_catalog_p0/test_mysql_jdbc_catalog.out
@@ -208,3 +208,8 @@ sys
-- !ex_tb1 --
{"k1":"v1", "k2":"v2"}
+-- !mysql_all_types --
+\N 302 \N 502 602 4.14159 \N 6.14159 \N -124
-302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345700
2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N
09:11:09.567 text2 \\xe86f6c6c6f20576f726c67 \N \N \\x2f
\N \\x88656c6c9f Value3
+201 301 401 501 601 3.14159 4.1415926 5.14159 true
-123 -301 2012 -401 -501 -601 2012-10-30
2012-10-25T12:05:36.345700 2012-10-25T08:08:08 -4.14145
-5.1400000001 -6.1400 row1 line1 09:09:09.567 text1
\\x48656c6c6f20576f726c64 {"age": 30, "city": "London", "name": "Alice"}
Option1,Option3 \\x2a \\x48656c6c6f00000000000000 \\x48656c6c6f Value2
+202 302 402 502 602 4.14159 5.1415926 6.14159 false
-124 -302 2013 -402 -502 -602 2012-11-01
2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145
-6.1400000001 -7.1400 row2 line2 09:11:09.567 text2
\\xe86f6c6c6f20576f726c67 {"age": 18, "city": "ChongQing", "name":
"Gaoxin"} Option1,Option2 \\x2f \\x58676c6c6f00000000000000
\\x88656c6c9f Value3
+203 303 403 503 603 7.14159 8.1415926 9.14159 false
\N -402 2017 -602 -902 -1102 2012-11-02
2023-05-22T16:01:20.063700 2013-10-27T08:11:18 -5.14145
-6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3
\\xe86f6c6c6f20576f726c67 {"age": 24, "city": "ChongQing", "name":
"ChenQi"} Option2 \\x2f \\x58676c6c6f00000000000000 \N Value1
diff --git
a/regression-test/suites/jdbc_catalog_p0/test_mysql_jdbc_catalog.groovy
b/regression-test/suites/jdbc_catalog_p0/test_mysql_jdbc_catalog.groovy
index b0e9409ebe..2f503ea68d 100644
--- a/regression-test/suites/jdbc_catalog_p0/test_mysql_jdbc_catalog.groovy
+++ b/regression-test/suites/jdbc_catalog_p0/test_mysql_jdbc_catalog.groovy
@@ -216,6 +216,11 @@ suite("test_mysql_jdbc_catalog", "p0") {
sql """ switch ${catalog_name} """
sql """ use ${ex_db_name} """
order_qt_ex_tb1 """ select * from ${ex_tb1} order by id; """
+
+ // test all types supported by MySQL
+ sql """use doris_test;"""
+ qt_mysql_all_types """select * from all_types order by tinyint_u;"""
+
sql """ drop catalog if exists ${catalog_name} """
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]