Skip to content

Commit

Permalink
[fix](regression-test) add tests for jdbc catalog (apache#26608) (apa…
Browse files Browse the repository at this point in the history
  • Loading branch information
BePPPower authored and gnehil committed Dec 4, 2023
1 parent c632383 commit 3ced316
Show file tree
Hide file tree
Showing 10 changed files with 394 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docker/thirdparties/docker-compose/oracle/init/03-create-table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
15 changes: 15 additions & 0 deletions docker/thirdparties/docker-compose/oracle/init/04-insert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ suite("test_mysql_jdbc_catalog", "p0,external,mysql,external_docker,external_doc
String ex_tb21 = "test_key_word";
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";
Expand Down Expand Up @@ -87,6 +89,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()"""
Expand Down Expand Up @@ -247,6 +289,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
Expand Down
Loading

0 comments on commit 3ced316

Please sign in to comment.