From 75f9710974e0f061bc27f825124655feea6bcc98 Mon Sep 17 00:00:00 2001 From: Tiewei Fang <43782773+BePPPower@users.noreply.github.com> Date: Thu, 9 Nov 2023 11:59:35 +0800 Subject: [PATCH] [fix](regression-test) add tests for jdbc catalog (#26608) --- .../oracle/init/03-create-table.sql | 37 +++++++++++ .../docker-compose/oracle/init/04-insert.sql | 15 +++++ .../postgresql/init/02-create-table.sql | 28 ++++++++ .../postgresql/init/04-insert.sql | 7 ++ docs/en/docs/lakehouse/multi-catalog/jdbc.md | 1 + .../docs/lakehouse/multi-catalog/jdbc.md | 1 + .../jdbc/test_mysql_jdbc_catalog.out | 46 +++++++++++++ .../jdbc/test_oracle_jdbc_catalog.out | 47 ++++++++++++++ .../jdbc/test_pg_jdbc_catalog.out | 39 +++++++++++ .../jdbc/test_mysql_jdbc_catalog.groovy | 57 +++++++++++++++++ .../jdbc/test_oracle_jdbc_catalog.groovy | 64 +++++++++++++++++++ .../jdbc/test_pg_jdbc_catalog.groovy | 54 ++++++++++++++++ 12 files changed, 396 insertions(+) diff --git a/docker/thirdparties/docker-compose/oracle/init/03-create-table.sql b/docker/thirdparties/docker-compose/oracle/init/03-create-table.sql index 829e2925a637e1..046f18c0dc65fc 100644 --- a/docker/thirdparties/docker-compose/oracle/init/03-create-table.sql +++ b/docker/thirdparties/docker-compose/oracle/init/03-create-table.sql @@ -131,3 +131,40 @@ name varchar2(20), age number(2), score number(3,1) ); + + +create table doris_test.test_all_types ( + id int, + n1 number, + n2 number(38), + n3 number(9,2), + n4 int, + n5 smallint, + n6 decimal(5,2), + n7 float, + n8 float(2), + n9 real, + tinyint_value1 number(2,0), + smallint_value1 number(4,0), + int_value1 number(9,0), + bigint_value1 number(18,0), + tinyint_value2 number(3,0), + smallint_value2 number(5,0), + int_value2 number(10,0), + bigint_value2 number(19,0), + country char, + city nchar(6), + address varchar2(4000), + name nvarchar2(6), + remark long, + num1 NUMBER(5,2), + num2 NUMBER(5, -2), + num4 NUMBER(5,7), + t1 date, + t2 timestamp(3), + t3 timestamp(6), + t4 timestamp(9), + t5 timestamp, + t6 interval year(3) to month, + t7 interval day(3) to second(6) +); diff --git a/docker/thirdparties/docker-compose/oracle/init/04-insert.sql b/docker/thirdparties/docker-compose/oracle/init/04-insert.sql index 17f68f994a237a..888cdf5bf7e4e4 100644 --- a/docker/thirdparties/docker-compose/oracle/init/04-insert.sql +++ b/docker/thirdparties/docker-compose/oracle/init/04-insert.sql @@ -86,4 +86,19 @@ insert into doris_test."student2" values (2, 'bob', 21, 90.5); insert into doris_test."student2" values (3, 'jerry', 23, 88.0); insert into doris_test."student2" values (4, 'andy', 21, 93); +insert into doris_test.test_all_types values +(1, 111, 123, 7456123.89, 573, 34, 673.43, 34.1264, 56.2, 23.231, +99, 9999, 999999999, 999999999999999999, 999, 99999, 9999999999, 9999999999999999999, +'1', 'china', 'beijing', 'alice', 'abcdefghrjkmnopq', +123.45, 12345, 0.0012345, +to_date('2022-1-21 5:23:01','yyyy-mm-dd hh24:mi:ss'), to_timestamp('20191112203357.999', 'yyyymmddhh24miss.ff'), to_timestamp('20191112203357.999997623', 'yyyymmddhh24miss.ff'), to_timestamp_tz('20191112203357.999996623', 'yyyymmddhh24miss.ff'), to_timestamp_tz('20191112203357.999996623', 'yyyymmddhh24miss.ff'), interval '223-9' year(3) to month, interval '12 10:23:01.1234568' day to second +); +insert into doris_test.test_all_types values +(2, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, +null, null, null, null, null, +null, null, null, +null, null, null, null, null, null, null +); + commit; diff --git a/docker/thirdparties/docker-compose/postgresql/init/02-create-table.sql b/docker/thirdparties/docker-compose/postgresql/init/02-create-table.sql index 92952cdd229141..a026e560d05253 100644 --- a/docker/thirdparties/docker-compose/postgresql/init/02-create-table.sql +++ b/docker/thirdparties/docker-compose/postgresql/init/02-create-table.sql @@ -151,6 +151,34 @@ CREATE TABLE catalog_pg_test.test12 ( uuid_value uuid ); +CREATE TABLE catalog_pg_test.test_all_types ( + ID INT NOT NULL, + char_value char(100), + varchar_value varchar(128), + date_value date, + smallint_value smallint, + int_value int, + bigint_value bigint, + timestamp_value timestamp, + decimal_value decimal(10, 3), + bit_value bit, + real_value real, + cidr_value cidr, + inet_value inet, + macaddr_value macaddr, + bitn_value bit(10), + bitnv_value bit varying(10), + serial4_value serial4, + jsonb_value jsonb, + point_value point, + line_value line, + lseg_value lseg, + box_value box, + path_value path, + polygon_value polygon, + circle_value circle +); + CREATE TABLE catalog_pg_test.test_insert ( id varchar(128), name varchar(128), diff --git a/docker/thirdparties/docker-compose/postgresql/init/04-insert.sql b/docker/thirdparties/docker-compose/postgresql/init/04-insert.sql index 245e70b2b2f6d1..2ea1e15b8be7f7 100644 --- a/docker/thirdparties/docker-compose/postgresql/init/04-insert.sql +++ b/docker/thirdparties/docker-compose/postgresql/init/04-insert.sql @@ -2656,6 +2656,13 @@ insert into catalog_pg_test.test12 values insert into catalog_pg_test.test12 values (2, '980dd890-f7fe-4fff-999d-873516108b2e'); +insert into catalog_pg_test.test_all_types values +(1, 'abc', 'def', '2022-10-11', 1, 2, 3, '2022-10-22 10:59:59', 34.123, cast(0 as bit), 12.123456, '10.16.10.14','10.16.10.14','ff:ff:ff:ff:ff:AA', +'1010101010', cast(10 as bit(5)), 1, '{"id":1}', '(1,1)', '{1,1,1}', '(1,1),(2,2)', '(1,1),(2,2)', '(1,1),(2,2),(2,1)', +'((1,1),(2,2),(2,1))', '<(0,0),1>'), +(2, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, 2, null, null, null, null, null, null, null, null); + INSERT INTO catalog_pg_test.wkb_test (location) SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326)); INSERT INTO catalog_pg_test.dt_test (ts_field, tzt_field) diff --git a/docs/en/docs/lakehouse/multi-catalog/jdbc.md b/docs/en/docs/lakehouse/multi-catalog/jdbc.md index dbdac58f78c1f8..38dfb47e4ffb7e 100644 --- a/docs/en/docs/lakehouse/multi-catalog/jdbc.md +++ b/docs/en/docs/lakehouse/multi-catalog/jdbc.md @@ -198,6 +198,7 @@ CREATE CATALOG jdbc_mysql PROPERTIES ( | FLOAT | FLOAT | | | DOUBLE | DOUBLE | | | DECIMAL | DECIMAL | | +| UNSIGNED DECIMAL(p,s) | DECIMAL(p+1,s) / STRING | If p+1>38, the Doris STRING type will be used. | | DATE | DATE | | | TIMESTAMP | DATETIME | | | DATETIME | DATETIME | | diff --git a/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md b/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md index f16a0bedd5a1c2..5605fdeca6133e 100644 --- a/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md +++ b/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md @@ -198,6 +198,7 @@ CREATE CATALOG jdbc_mysql PROPERTIES ( | FLOAT | FLOAT | | | DOUBLE | DOUBLE | | | DECIMAL | DECIMAL | | +| UNSIGNED DECIMAL(p,s) | DECIMAL(p+1,s) / STRING | 如果p+1>38, 将使用Doris STRING类型 | | DATE | DATE | | | TIMESTAMP | DATETIME | | | DATETIME | DATETIME | | diff --git a/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out b/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out index d5cc90fa80f0d0..e406905ec4af28 100644 --- a/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out +++ b/regression-test/data/external_table_p0/jdbc/test_mysql_jdbc_catalog.out @@ -279,6 +279,52 @@ sys 202 302 402 502 602 4.14159 5.1415926 6.14159 0 -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 0xE86F6C6C6F20576F726C67 {"age":18,"city":"ChongQing","name":"Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3 203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3 0xE86F6C6C6F20576F726C67 {"age":24,"city":"ChongQing","name":"ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1 +-- !select_insert_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 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3 +201 301 401 501 601 3.14159 4.1415926 5.14159 1 -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 0x48656C6C6F20576F726C64 {"age":30,"city":"London","name":"Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2 +202 302 402 502 602 4.14159 5.1415926 6.14159 0 -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 0xE86F6C6C6F20576F726C67 {"age":18,"city":"ChongQing","name":"Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3 +203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3 0xE86F6C6C6F20576F726C67 {"age":24,"city":"ChongQing","name":"ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1 + +-- !ctas -- +\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 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3 +201 301 401 501 601 3.14159 4.1415926 5.14159 1 -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 0x48656C6C6F20576F726C64 {"age":30,"city":"London","name":"Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2 +202 302 402 502 602 4.14159 5.1415926 6.14159 0 -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 0xE86F6C6C6F20576F726C67 {"age":18,"city":"ChongQing","name":"Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3 +203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3 0xE86F6C6C6F20576F726C67 {"age":24,"city":"ChongQing","name":"ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1 + +-- !ctas_desc -- +bigint BIGINT Yes false \N NONE +bigint_u LARGEINT Yes false \N NONE +binary TEXT Yes false \N NONE +bit TEXT Yes false \N NONE +blob TEXT Yes false \N NONE +boolean TINYINT Yes false \N NONE +char VARCHAR(*) Yes false \N NONE +date DATE Yes false \N NONE +datetime DATETIME Yes false \N NONE +decimal DECIMAL(12, 4) Yes false \N NONE +decimal_u DECIMAL(19, 5) Yes false \N NONE +double DOUBLE Yes false \N NONE +double_u DOUBLE Yes false \N NONE +enum TEXT Yes false \N NONE +float FLOAT Yes false \N NONE +float_u FLOAT Yes false \N NONE +int INT Yes false \N NONE +int_u BIGINT Yes false \N NONE +json JSON Yes false \N NONE +mediumint INT Yes false \N NONE +mediumint_u INT Yes true \N +set TEXT Yes false \N NONE +smallint SMALLINT Yes false \N NONE +smallint_u INT Yes true \N +text TEXT Yes false \N NONE +time TEXT Yes false \N NONE +timestamp DATETIME(4) Yes false \N NONE +tinyint TINYINT Yes false \N NONE +tinyint_u SMALLINT Yes true \N +varbinary TEXT Yes false \N NONE +varchar VARCHAR(10) Yes false \N NONE +year SMALLINT Yes false \N NONE + -- !mysql_view -- 10086 4294967295 201 diff --git a/regression-test/data/external_table_p0/jdbc/test_oracle_jdbc_catalog.out b/regression-test/data/external_table_p0/jdbc/test_oracle_jdbc_catalog.out index 1be0feb1a90a66..519c7ab131cd98 100644 --- a/regression-test/data/external_table_p0/jdbc/test_oracle_jdbc_catalog.out +++ b/regression-test/data/external_table_p0/jdbc/test_oracle_jdbc_catalog.out @@ -115,6 +115,53 @@ doris2 19 doris3 20 doris3 20 +-- !select_all_types -- +1 111 123 7456123.89 573 34 673.43 34.1264 60.0 23.231 99 9999 999999999 999999999999999999 999 99999 9999999999 9999999999999999999 1 china beijing alice abcdefghrjkmnopq 123.45 12300 0.0012345 2022-01-21T05:23:01 2019-11-12T20:33:57.999 2019-11-12T20:33:57.999998 2019-11-12T20:33:57.999996 2019-11-12T20:33:57.999997 223-9 12 10:23:1.123457 +2 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N + +-- !ctas -- +1 111 123 7456123.89 573 34 673.43 34.1264 60.0 23.231 99 9999 999999999 999999999999999999 999 99999 9999999999 9999999999999999999 1 china beijing alice abcdefghrjkmnopq 123.45 12300 0.0012345 2022-01-21T05:23:01 2019-11-12T20:33:57.999 2019-11-12T20:33:57.999998 2019-11-12T20:33:57.999996 2019-11-12T20:33:57.999997 223-9 12 10:23:1.123457 +2 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N + +-- !ctas_desc -- +ADDRESS TEXT Yes false \N NONE +BIGINT_VALUE1 BIGINT Yes false \N NONE +BIGINT_VALUE2 LARGEINT Yes false \N NONE +CITY TEXT Yes false \N NONE +COUNTRY TEXT Yes false \N NONE +ID LARGEINT Yes true \N +INT_VALUE1 INT Yes false \N NONE +INT_VALUE2 BIGINT Yes false \N NONE +N1 TEXT Yes false \N NONE +N2 LARGEINT Yes false \N NONE +N3 DECIMAL Yes false \N NONE +N4 LARGEINT Yes false \N NONE +N5 LARGEINT Yes false \N NONE +N6 DECIMAL(5, 2) Yes false \N NONE +N7 DOUBLE Yes false \N NONE +N8 DOUBLE Yes false \N NONE +N9 DOUBLE Yes false \N NONE +NAME TEXT Yes false \N NONE +NUM1 DECIMAL(5, 2) Yes false \N NONE +NUM2 INT Yes false \N NONE +NUM4 DECIMAL(7, 7) Yes false \N NONE +REMARK TEXT Yes false \N NONE +SMALLINT_VALUE1 SMALLINT Yes false \N NONE +SMALLINT_VALUE2 INT Yes false \N NONE +T1 DATETIME Yes false \N NONE +T2 DATETIME(3) Yes false \N NONE +T3 DATETIME(6) Yes false \N NONE +T4 DATETIME(6) Yes false \N NONE +T5 DATETIME(6) Yes false \N NONE +T6 TEXT Yes false \N NONE +T7 TEXT Yes false \N NONE +TINYINT_VALUE1 TINYINT Yes false \N NONE +TINYINT_VALUE2 SMALLINT Yes false \N NONE + +-- !select_insert_all_types -- +1 111 123 7456123.89 573 34 673.43 34.1264 60.0 23.231 99 9999 999999999 999999999999999999 999 99999 9999999999 9999999999999999999 1 china beijing alice abcdefghrjkmnopq 123.45 12300 0.0012345 2022-01-21T05:23:01 2019-11-12T20:33:57.999 2019-11-12T20:33:57.999998 2019-11-12T20:33:57.999996 2019-11-12T20:33:57.999997 223-9 12 10:23:1.123457 +2 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N + -- !specified_database -- DORIS_TEST diff --git a/regression-test/data/external_table_p0/jdbc/test_pg_jdbc_catalog.out b/regression-test/data/external_table_p0/jdbc/test_pg_jdbc_catalog.out index 1a2cf62abf0ed6..b2a944cde6a160 100644 --- a/regression-test/data/external_table_p0/jdbc/test_pg_jdbc_catalog.out +++ b/regression-test/data/external_table_p0/jdbc/test_pg_jdbc_catalog.out @@ -2214,6 +2214,45 @@ doris2 19 doris3 20 doris3 20 +-- !select_all_types -- +1 abc def 2022-10-11 1 2 3 2022-10-22T10:59:59 34.123 false 12.123456 10.16.10.14/32 10.16.10.14 ff:ff:ff:ff:ff:aa 1010101010 01010 1 {"id":1} (1.0,1.0) {1.0,1.0,1.0} [(1.0,1.0),(2.0,2.0)] (2.0,2.0),(1.0,1.0) ((1.0,1.0),(2.0,2.0),(2.0,1.0)) ((1.0,1.0),(2.0,2.0),(2.0,1.0)) <(0.0,0.0),1.0> +2 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N 2 \N \N \N \N \N \N \N \N + +-- !ctas -- +1 abc def 2022-10-11 1 2 3 2022-10-22T10:59:59 34.123 false 12.123456 10.16.10.14/32 10.16.10.14 ff:ff:ff:ff:ff:aa 1010101010 01010 1 {"id":1} (1.0,1.0) {1.0,1.0,1.0} [(1.0,1.0),(2.0,2.0)] (2.0,2.0),(1.0,1.0) ((1.0,1.0),(2.0,2.0),(2.0,1.0)) ((1.0,1.0),(2.0,2.0),(2.0,1.0)) <(0.0,0.0),1.0> +2 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N 2 \N \N \N \N \N \N \N \N + +-- !ctas_desc -- +bigint_value BIGINT Yes false \N NONE +bit_value BOOLEAN Yes false \N NONE +bitn_value TEXT Yes false \N NONE +bitnv_value TEXT Yes false \N NONE +box_value TEXT Yes false \N NONE +char_value VARCHAR(*) Yes true \N +cidr_value TEXT Yes false \N NONE +circle_value TEXT Yes false \N NONE +date_value DATE Yes false \N NONE +decimal_value DECIMAL(10, 3) Yes false \N NONE +id INT No true \N +inet_value TEXT Yes false \N NONE +int_value INT Yes false \N NONE +jsonb_value JSON Yes false \N NONE +line_value TEXT Yes false \N NONE +lseg_value TEXT Yes false \N NONE +macaddr_value TEXT Yes false \N NONE +path_value TEXT Yes false \N NONE +point_value TEXT Yes false \N NONE +polygon_value TEXT Yes false \N NONE +real_value FLOAT Yes false \N NONE +serial4_value INT No false \N NONE +smallint_value SMALLINT Yes false \N NONE +timestamp_value DATETIME(6) Yes false \N NONE +varchar_value TEXT Yes false \N NONE + +-- !select_insert_all_types -- +1 abc def 2022-10-11 1 2 3 2022-10-22T10:59:59 34.123 false 12.123456 10.16.10.14/32 10.16.10.14 ff:ff:ff:ff:ff:aa 1010101010 01010 1 {"id":1} (1.0,1.0) {1.0,1.0,1.0} [(1.0,1.0),(2.0,2.0)] (2.0,2.0),(1.0,1.0) ((1.0,1.0),(2.0,2.0),(2.0,1.0)) ((1.0,1.0),(2.0,2.0),(2.0,1.0)) <(0.0,0.0),1.0> +2 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N 2 \N \N \N \N \N \N \N \N + -- !specified_database_1 -- doris_test diff --git a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy index 771a272e9b30cb..09a8520b7ac6bd 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy @@ -56,6 +56,8 @@ suite("test_mysql_jdbc_catalog", "p0,external,mysql,external_docker,external_doc String ex_tb20 = "ex_tb20"; String test_insert = "test_insert"; String test_insert2 = "test_insert2"; + String test_insert_all_types = "test_insert_all_types"; + String test_ctas = "test_ctas"; String auto_default_t = "auto_default_t"; String dt = "dt"; String dt_null = "dt_null"; @@ -86,6 +88,46 @@ suite("test_mysql_jdbc_catalog", "p0,external,mysql,external_docker,external_doc PROPERTIES("replication_num" = "1"); """ + // used for testing all types + sql """ drop table if exists ${internal_db_name}.${test_insert_all_types} """ + sql """ + CREATE TABLE ${internal_db_name}.${test_insert_all_types} ( + `tinyint_u` SMALLINT, + `smallint_u` INT, + `mediumint_u` INT, + `int_u` BIGINT, + `bigint_u` LARGEINT, + `decimal_u` DECIMAL(18, 5), + `double_u` DOUBLE, + `float_u` FLOAT, + `boolean` TINYINT, + `tinyint` TINYINT, + `smallint` SMALLINT, + `year` SMALLINT, + `mediumint` INT, + `int` INT, + `bigint` BIGINT, + `date` DATE, + `timestamp` DATETIME(4) null, + `datetime` DATETIME, + `float` FLOAT, + `double` DOUBLE, + `decimal` DECIMAL(12, 4), + `char` CHAR(5), + `varchar` VARCHAR(10), + `time` STRING, + `text` STRING, + `blob` STRING, + `json` JSON, + `set` STRING, + `bit` STRING, + `binary` STRING, + `varbinary` STRING, + `enum` STRING + ) DISTRIBUTED BY HASH(tinyint_u) BUCKETS 10 + PROPERTIES("replication_num" = "1"); + """ + qt_sql """select current_catalog()""" sql """switch ${catalog_name}""" qt_sql """select current_catalog()""" @@ -245,6 +287,21 @@ suite("test_mysql_jdbc_catalog", "p0,external,mysql,external_docker,external_doc sql """use doris_test;""" qt_mysql_all_types """select * from all_types order by tinyint_u;""" + // test insert into internal.db.table select * from all_types + sql """ insert into internal.${internal_db_name}.${test_insert_all_types} select * from all_types; """ + order_qt_select_insert_all_types """ select * from internal.${internal_db_name}.${test_insert_all_types} order by tinyint_u; """ + + // test CTAS + sql """ drop table if exists internal.${internal_db_name}.${test_ctas} """ + sql """ create table internal.${internal_db_name}.${test_ctas} + PROPERTIES("replication_num" = "1") + AS select * from all_types; + """ + + order_qt_ctas """select * from internal.${internal_db_name}.${test_ctas} order by tinyint_u;""" + + order_qt_ctas_desc """desc internal.${internal_db_name}.${test_ctas};""" + sql """ drop catalog if exists ${catalog_name} """ // test mysql view diff --git a/regression-test/suites/external_table_p0/jdbc/test_oracle_jdbc_catalog.groovy b/regression-test/suites/external_table_p0/jdbc/test_oracle_jdbc_catalog.groovy index 77d3015239c27d..e762f2f4aaf41f 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_oracle_jdbc_catalog.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_oracle_jdbc_catalog.groovy @@ -29,6 +29,9 @@ suite("test_oracle_jdbc_catalog", "p0,external,oracle,external_docker,external_d String oracle_port = context.config.otherConfigs.get("oracle_11_port"); String SID = "XE"; String test_insert = "TEST_INSERT"; + String test_all_types = "TEST_ALL_TYPES"; + String test_insert_all_types = "test_insert_all_types"; + String test_ctas = "test_ctas"; String inDorisTable = "doris_in_tb"; @@ -55,6 +58,49 @@ suite("test_oracle_jdbc_catalog", "p0,external,oracle,external_docker,external_d PROPERTIES("replication_num" = "1"); """ + sql """ drop table if exists ${internal_db_name}.${test_insert_all_types} """ + sql """ + CREATE TABLE ${internal_db_name}.${test_insert_all_types} ( + `ID` LARGEINT NULL, + `N1` TEXT NULL, + `N2` LARGEINT NULL, + `N3` DECIMAL(9, 2) NULL, + `N4` LARGEINT NULL, + `N5` LARGEINT NULL, + `N6` DECIMAL(5, 2) NULL, + `N7` DOUBLE NULL, + `N8` DOUBLE NULL, + `N9` DOUBLE NULL, + `TINYINT_VALUE1` TINYINT NULL, + `SMALLINT_VALUE1` SMALLINT NULL, + `INT_VALUE1` INT NULL, + `BIGINT_VALUE1` BIGINT NULL, + `TINYINT_VALUE2` SMALLINT NULL, + `SMALLINT_VALUE2` INT NULL, + `INT_VALUE2` BIGINT NULL, + `BIGINT_VALUE2` LARGEINT NULL, + `COUNTRY` TEXT NULL, + `CITY` TEXT NULL, + `ADDRESS` TEXT NULL, + `NAME` TEXT NULL, + `REMARK` TEXT NULL, + `NUM1` DECIMAL(5, 2) NULL, + `NUM2` INT NULL, + `NUM4` DECIMAL(7, 7) NULL, + `T1` DATETIME NULL, + `T2` DATETIME(3) NULL, + `T3` DATETIME(6) NULL, + `T4` DATETIME(6) NULL, + `T5` DATETIME(6) NULL, + `T6` TEXT NULL, + `T7` TEXT NULL + ) + DISTRIBUTED BY HASH(`ID`) BUCKETS 10 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + """ + sql """switch ${catalog_name}""" sql """ use ${ex_db_name}""" @@ -98,6 +144,24 @@ suite("test_oracle_jdbc_catalog", "p0,external,oracle,external_docker,external_d sql """ insert into ${test_insert} select * from ${test_insert} where id = '${uuid2}' """ order_qt_test_insert3 """ select name, age from ${test_insert} where id = '${uuid2}' order by age """ + // test select all types + order_qt_select_all_types """select * from ${test_all_types}; """ + + // test test ctas + sql """ drop table if exists internal.${internal_db_name}.${test_ctas} """ + sql """ create table internal.${internal_db_name}.${test_ctas} + PROPERTIES("replication_num" = "1") + AS select * from ${test_all_types}; + """ + + order_qt_ctas """select * from internal.${internal_db_name}.${test_ctas};""" + + order_qt_ctas_desc """desc internal.${internal_db_name}.${test_ctas};""" + + // test insert into internal.db.tbl + sql """ insert into internal.${internal_db_name}.${test_insert_all_types} select * from ${test_all_types}; """ + order_qt_select_insert_all_types """ select * from internal.${internal_db_name}.${test_insert_all_types} order by id; """ + sql """drop catalog if exists ${catalog_name} """ // test only_specified_database argument diff --git a/regression-test/suites/external_table_p0/jdbc/test_pg_jdbc_catalog.groovy b/regression-test/suites/external_table_p0/jdbc/test_pg_jdbc_catalog.groovy index f92bb37be68cf9..0df873e96ac8cd 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_pg_jdbc_catalog.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_pg_jdbc_catalog.groovy @@ -29,6 +29,9 @@ suite("test_pg_jdbc_catalog", "p0,external,pg,external_docker,external_docker_pg String pg_port = context.config.otherConfigs.get("pg_14_port"); String inDorisTable = "test_pg_jdbc_doris_in_tb"; String test_insert = "test_insert"; + String test_all_types = "test_all_types"; + String test_insert_all_types = "test_insert_all_types"; + String test_ctas = "test_ctas"; sql """create database if not exists ${internal_db_name}; """ @@ -51,6 +54,38 @@ suite("test_pg_jdbc_catalog", "p0,external,pg,external_docker,external_docker_pg ) DISTRIBUTED BY HASH(id) BUCKETS 10 PROPERTIES("replication_num" = "1"); """ + sql """ drop table if exists ${internal_db_name}.${test_insert_all_types} """ + sql """ + CREATE TABLE ${internal_db_name}.${test_insert_all_types} ( + `id` INT NOT NULL, + `char_value` VARCHAR(*) NULL, + `varchar_value` TEXT NULL, + `date_value` DATE NULL, + `smallint_value` SMALLINT NULL, + `int_value` INT NULL, + `bigint_value` BIGINT NULL, + `timestamp_value` DATETIME(6) NULL, + `decimal_value` DECIMAL(10, 3) NULL, + `bit_value` BOOLEAN NULL, + `real_value` FLOAT NULL, + `cidr_value` TEXT NULL, + `inet_value` TEXT NULL, + `macaddr_value` TEXT NULL, + `bitn_value` TEXT NULL, + `bitnv_value` TEXT NULL, + `serial4_value` INT NOT NULL, + `jsonb_value` JSON NULL, + `point_value` TEXT NULL, + `line_value` TEXT NULL, + `lseg_value` TEXT NULL, + `box_value` TEXT NULL, + `path_value` TEXT NULL, + `polygon_value` TEXT NULL, + `circle_value` TEXT NULL + ) + DISTRIBUTED BY HASH(`id`) BUCKETS 10 + PROPERTIES("replication_num" = "1"); + """ sql """switch ${catalog_name}""" sql """ use ${ex_schema_name}""" @@ -105,6 +140,25 @@ suite("test_pg_jdbc_catalog", "p0,external,pg,external_docker,external_docker_pg sql """ insert into ${test_insert} select * from ${test_insert} where id = '${uuid2}' """ order_qt_test_insert3 """ select name, age from ${test_insert} where id = '${uuid2}' order by age """ + // test select all types + order_qt_select_all_types """select * from ${test_all_types}; """ + + // test test ctas + sql """ drop table if exists internal.${internal_db_name}.${test_ctas} """ + sql """ create table internal.${internal_db_name}.${test_ctas} + PROPERTIES("replication_num" = "1") + AS select * from ${test_all_types}; + """ + + order_qt_ctas """select * from internal.${internal_db_name}.${test_ctas};""" + + order_qt_ctas_desc """desc internal.${internal_db_name}.${test_ctas};""" + + // test insert into internal.db.tbl + sql """ insert into internal.${internal_db_name}.${test_insert_all_types} select * from ${test_all_types}; """ + order_qt_select_insert_all_types """ select * from internal.${internal_db_name}.${test_insert_all_types} order by id; """ + + sql """drop catalog if exists ${catalog_name} """ // test only_specified_database argument