From 66d2872f11add3f841569ffc0a7dc14a68f90c13 Mon Sep 17 00:00:00 2001 From: Yuhui Date: Mon, 5 Feb 2024 21:06:37 +0800 Subject: [PATCH] [#2034] Improvement (trino-connector): Add datatype , catalog test cases for the Trino connector (#2036) ### What changes were proposed in this pull request? Add datatype , catalog test cases for the Trino connector ### Why are the changes needed? Issue: #2034 ### Does this PR introduce _any_ user-facing change? NO ### How was this patch tested? TriniQueryIT --- .../testsets/hive/00006_datatype.sql | 35 +++++++++ .../testsets/hive/00006_datatype.txt | 42 +++++++++++ .../jdbc-mysql/00000_create_table.sql | 55 +++++++++++++- .../jdbc-mysql/00000_create_table.txt | 40 +++++++++++ .../jdbc-mysql/00001_select_table.sql | 4 +- .../jdbc-mysql/00001_select_table.txt | 6 +- .../testsets/jdbc-mysql/00002_alter_table.sql | 10 +++ .../testsets/jdbc-mysql/00002_alter_table.txt | 45 ++++++++++-- .../testsets/jdbc-mysql/00003_use.sql | 11 +++ .../testsets/jdbc-mysql/00003_use.txt | 17 +++++ .../testsets/jdbc-mysql/00005_catalog.sql | 53 ++++++++++++++ .../testsets/jdbc-mysql/00005_catalog.txt | 23 ++++++ .../testsets/jdbc-mysql/00006_datatype.sql | 71 ++++++++++++++++++ .../testsets/jdbc-mysql/00006_datatype.txt | 72 +++++++++++++++++++ .../jdbc-postgresql/00004_query_pushdown.txt | 3 +- .../jdbc-postgresql/00006_datatype.sql | 72 +++++++++++++++++++ .../jdbc-postgresql/00006_datatype.txt | 66 +++++++++++++++++ .../lakehouse-iceberg/00001_select_table.txt | 2 - .../lakehouse-iceberg/00006_datatype.sql | 69 ++++++++++++++++++ .../lakehouse-iceberg/00006_datatype.txt | 65 +++++++++++++++++ .../connector/DummyGravitinoConnector.java | 4 +- 21 files changed, 748 insertions(+), 17 deletions(-) create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.sql create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.txt create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.sql create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.txt create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.sql create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.txt create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.sql create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.txt create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.sql create mode 100644 integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.txt diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.sql new file mode 100644 index 00000000000..a58417f6710 --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.sql @@ -0,0 +1,35 @@ +CREATE SCHEMA "test.gt_hive".gt_db1; + +USE "test.gt_hive".gt_db1; + +-- Unsupported Type: TIME +CREATE TABLE tb01 ( + f1 VARCHAR(200), + f2 CHAR(20), + f3 VARBINARY, + f4 DECIMAL(10, 3), + f5 REAL, + f6 DOUBLE, + f7 BOOLEAN, + f8 TINYINT, + f9 SMALLINT, + f10 INT, + f11 INTEGER, + f12 BIGINT, + f13 DATE, + f15 TIMESTAMP +); + +SHOW CREATE TABLE tb01; + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f15) +VALUES ('Sample text 1', 'Text1', x'65', 123.456, 7.89, 12.34, false, 1, 100, 1000, 1000, 100000, DATE '2024-01-01', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f15) +VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + +select * from tb01 order by f1; + +drop table tb01; + +drop schema "test.gt_hive".gt_db1 cascade; diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.txt new file mode 100644 index 00000000000..e4269caa0f1 --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00006_datatype.txt @@ -0,0 +1,42 @@ +CREATE SCHEMA + +USE + +CREATE TABLE + +"CREATE TABLE ""test.gt_hive"".gt_db1.tb01 ( + f1 varchar(200), + f2 char(20), + f3 varbinary, + f4 decimal(10, 3), + f5 real, + f6 double, + f7 boolean, + f8 tinyint, + f9 smallint, + f10 integer, + f11 integer, + f12 bigint, + f13 date, + f15 timestamp(3) +) +COMMENT '' +WITH ( + input_format = 'org.apache.hadoop.mapred.TextInputFormat', + location = 'hdfs://%:9000/user/hive/warehouse/gt_db1.db/tb01', + output_format = 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat', + serde_lib = 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe', + serde_name = 'tb01', + table_type = 'MANAGED_TABLE' +)" + +INSERT: 1 row + +INSERT: 1 row + +"Sample text 1","Text1 ","65","123.456","7.89","12.34","false","1","100","1000","1000","100000","2024-01-01","2024-01-01 08:00:00.000" +"","","","","","","","","","","","","","" + +DROP TABLE + +DROP SCHEMA diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql index 3b2c9487606..09e50a1becb 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql @@ -1,12 +1,61 @@ CREATE SCHEMA "test.gt_mysql".gt_db1; +SHOW SCHEMAS FROM "test.gt_mysql" like 'gt_db1'; + +SHOW CREATE SCHEMA "test.gt_mysql".gt_db1; + +CREATE SCHEMA "test.gt_mysql".gt_db1; + +CREATE SCHEMA IF NOT EXISTS "test.gt_mysql".gt_db1; + +CREATE SCHEMA IF NOT EXISTS "test.gt_mysql".gt_db2; + +SHOW SCHEMAS FROM "test.gt_mysql" like 'gt_db2'; + CREATE TABLE "test.gt_mysql".gt_db1.tb01 ( name varchar(200), salary int ); -show create table "test.gt_mysql".gt_db1.tb01; +SHOW CREATE TABLE "test.gt_mysql".gt_db1.tb01; + +SHOW tables FROM "test.gt_mysql".gt_db1 like 'tb01'; + +CREATE TABLE "test.gt_mysql".gt_db1.tb01 ( + name varchar(200), + salary int +); + +CREATE TABLE IF NOT EXISTS "test.gt_mysql".gt_db1.tb01 ( + name varchar(200), + salary int +); + +CREATE TABLE IF NOT EXISTS "test.gt_mysql".gt_db1.tb02 ( + name varchar(200), + salary int +); + +SHOW tables FROM "test.gt_mysql".gt_db1 like 'tb02'; + +DROP TABLE "test.gt_mysql".gt_db1.tb01; + +SHOW tables FROM "test.gt_mysql".gt_db1 like 'tb01'; + +DROP TABLE "test.gt_mysql".gt_db1.tb01; + +DROP TABLE IF EXISTS "test.gt_mysql".gt_db1.tb01; + +DROP TABLE IF EXISTS "test.gt_mysql".gt_db1.tb02; + +SHOW tables FROM "test.gt_mysql".gt_db1 like 'tb02'; + +DROP SCHEMA "test.gt_mysql".gt_db1; + +SHOW SCHEMAS FROM "test.gt_mysql" like 'gt_db1'; + +DROP SCHEMA IF EXISTS "test.gt_mysql".gt_db1; -drop table "test.gt_mysql".gt_db1.tb01; +DROP SCHEMA IF EXISTS "test.gt_mysql".gt_db2; -drop schema "test.gt_mysql".gt_db1; \ No newline at end of file +SHOW SCHEMAS FROM "test.gt_mysql" like 'gt_db2' diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt index 21188b9fa71..7b78fbe07b6 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt @@ -1,5 +1,17 @@ CREATE SCHEMA +"gt_db1" + +"CREATE SCHEMA ""test.gt_mysql"".gt_db1" + + Schema 'test.gt_mysql.gt_db1' already exists + +CREATE SCHEMA + +CREATE SCHEMA + +"gt_db2" + CREATE TABLE "CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( @@ -11,6 +23,34 @@ WITH ( engine = 'InnoDB' )" +"tb01" + + Table 'test.gt_mysql.gt_db1.tb01' already exists + +CREATE TABLE + +CREATE TABLE + +"tb02" + +DROP TABLE + + + + Table 'test.gt_mysql.gt_db1.tb01' does not exist + +DROP TABLE + DROP TABLE + + +DROP SCHEMA + + + DROP SCHEMA + +DROP SCHEMA + + diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.sql index cc3ddfa961d..51fc9066bdd 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.sql +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.sql @@ -20,8 +20,10 @@ insert into "test.gt_mysql".gt_db1.tb02(name, salary) select distinct * from "te select * from "test.gt_mysql".gt_db1.tb02 order by name; +select * from "test.gt_mysql".gt_db1.tb01 join "test.gt_mysql".gt_db1.tb02 t on tb01.salary = t.salary order by tb01.name; + drop table "test.gt_mysql".gt_db1.tb02; drop table "test.gt_mysql".gt_db1.tb01; -drop schema "test.gt_mysql".gt_db1; \ No newline at end of file +drop schema "test.gt_mysql".gt_db1; diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.txt index f5aa32125e3..e61b06b0772 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00001_select_table.txt @@ -22,10 +22,14 @@ INSERT: 4 rows "sam","11" "tom","12" +"bob","14","bob","14" +"jerry","13","jerry","13" +"sam","11","sam","11" +"tom","12","tom","12" + DROP TABLE DROP TABLE DROP SCHEMA - diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.sql index 9d4a7c0d517..0ce7326cadf 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.sql +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.sql @@ -18,6 +18,16 @@ show create table "test.gt_mysql".gt_db1.tb01; alter table "test.gt_mysql".gt_db1.tb01 alter column salary set data type bigint; show create table "test.gt_mysql".gt_db1.tb01; +comment on column "test.gt_mysql".gt_db1.tb01.name is 'test column comments'; +show create table "test.gt_mysql".gt_db1.tb01; + +comment on table "test.gt_mysql".gt_db1.tb01 is 'test table comments'; +show create table "test.gt_mysql".gt_db1.tb01; + +alter table "test.gt_mysql".gt_db1.tb01 rename column name to s; +show create table "test.gt_mysql".gt_db1.tb01; + +-- alter table "test.gt_mysql".gt_db1.tb01 add column city varchar(50) not null comment 'aaa'; alter table "test.gt_mysql".gt_db1.tb01 add column city varchar(50) comment 'aaa'; show create table "test.gt_mysql".gt_db1.tb01; diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt index 6fa0269d5ba..2ace13f5db0 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt @@ -32,14 +32,47 @@ WITH ( engine = 'InnoDB' )" +COMMENT + +"CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( + name varchar(200) COMMENT 'test column comments', + salary bigint +) +COMMENT '' +WITH ( + engine = 'InnoDB' +)" + +COMMENT + +"CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( + name varchar(200) COMMENT 'test column comments', + salary bigint +) +COMMENT 'test table comments' +WITH ( + engine = 'InnoDB' +)" + +RENAME COLUMN + +"CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( + s varchar(200) COMMENT 'test column comments', + salary bigint +) +COMMENT 'test table comments' +WITH ( + engine = 'InnoDB' +)" + ADD COLUMN "CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( - name varchar(200), + s varchar(200) COMMENT 'test column comments', salary bigint, city varchar(50) COMMENT 'aaa' ) -COMMENT '' +COMMENT 'test table comments' WITH ( engine = 'InnoDB' )" @@ -47,12 +80,12 @@ WITH ( ADD COLUMN "CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( - name varchar(200), + s varchar(200) COMMENT 'test column comments', salary bigint, city varchar(50) COMMENT 'aaa', age integer NOT NULL COMMENT 'age of users' ) -COMMENT '' +COMMENT 'test table comments' WITH ( engine = 'InnoDB' )" @@ -60,13 +93,13 @@ WITH ( ADD COLUMN "CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( - name varchar(200), + s varchar(200) COMMENT 'test column comments', salary bigint, city varchar(50) COMMENT 'aaa', age integer NOT NULL COMMENT 'age of users', address varchar(200) NOT NULL COMMENT 'address of users' ) -COMMENT '' +COMMENT 'test table comments' WITH ( engine = 'InnoDB' )" diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.sql index 5642df2823f..0b568e506a2 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.sql +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.sql @@ -9,6 +9,17 @@ CREATE TABLE tb01 ( show tables from "test.gt_mysql".gt_db1; +show tables; + +use tpch.tiny; + +show tables; + +USE "test.gt_mysql".gt_db1; + +show tables; + drop table tb01; drop schema "test.gt_mysql".gt_db1; + diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.txt index b2490524619..fc243af076e 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00003_use.txt @@ -6,6 +6,23 @@ CREATE TABLE "tb01" +"tb01" + +USE + +"customer" +"lineitem" +"nation" +"orders" +"part" +"partsupp" +"region" +"supplier" + +USE + +"tb01" + DROP TABLE DROP SCHEMA diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.sql new file mode 100644 index 00000000000..8236cca3508 --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.sql @@ -0,0 +1,53 @@ +call gravitino.system.create_catalog( + 'gt_mysql_xxx1', + 'jdbc-mysql', + map( + array['jdbc-url', 'jdbc-user', 'jdbc-password', 'jdbc-driver'], + array['${mysql_uri}/?useSSL=false', 'trino', 'ds123', 'com.mysql.cj.jdbc.Driver'] + ) +); + +show catalogs like 'test.gt_mysql_xxx1'; + +call gravitino.system.create_catalog( + 'gt_mysql_xxx1', + 'jdbc-mysql', + map( + array['jdbc-url', 'jdbc-user', 'jdbc-password', 'jdbc-driver'], + array['${mysql_uri}/?useSSL=false', 'trino', 'ds123', 'com.mysql.cj.jdbc.Driver'] + ) +); + +call gravitino.system.create_catalog( + catalog => 'gt_mysql_xxx1', + provider => 'jdbc-mysql', + properties => map( + array['jdbc-url', 'jdbc-user', 'jdbc-password', 'jdbc-driver'], + array['${mysql_uri}/?useSSL=false', 'trino', 'ds123', 'com.mysql.cj.jdbc.Driver'] + ), + ignore_exist => true +); + +CALL gravitino.system.drop_catalog('gt_mysql_xxx1'); + +show catalogs like 'test.gt_mysql_xxx1'; + +CALL gravitino.system.drop_catalog('gt_mysql_xxx1'); + +CALL gravitino.system.drop_catalog('gt_mysql_xxx1', true); + +call gravitino.system.create_catalog( + 'gt_mysql_xxx1', + 'jdbc-mysql', + map( + array['jdbc-url', 'jdbc-user', 'jdbc-password', 'jdbc-driver'], + array['${mysql_uri}/?useSSL=false', 'trino', 'ds123', 'com.mysql.cj.jdbc.Driver'] + ) +); + +show catalogs like 'test.gt_mysql_xxx1'; + +CALL gravitino.system.drop_catalog( + catalog => 'gt_mysql_xxx1', ignore_not_exist => true); + +show catalogs like 'test.gt_mysql_xxx1'; diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.txt new file mode 100644 index 00000000000..198a59bacb9 --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00005_catalog.txt @@ -0,0 +1,23 @@ +CALL + +"test.gt_mysql_xxx1" + + Catalog test.gt_mysql_xxx1 already exists. + +CALL + +CALL + + + + Drop catalog failed. Catalog test.gt_mysql_xxx1 not exists + +CALL + +CALL + +"test.gt_mysql_xxx1" + +CALL + + diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.sql new file mode 100644 index 00000000000..531d5d9921c --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.sql @@ -0,0 +1,71 @@ +CREATE SCHEMA "test.gt_mysql".gt_db1; + +USE "test.gt_mysql".gt_db1; + +-- Unsupported Type: BOOLEAN +CREATE TABLE tb01 ( + f1 VARCHAR(200), + f2 CHAR(20), + f3 VARBINARY, + f4 DECIMAL(10, 3), + f5 REAL, + f6 DOUBLE, + f8 TINYINT, + f9 SMALLINT, + f10 INT, + f11 INTEGER, + f12 BIGINT, + f13 DATE, + f14 TIME, + f15 TIMESTAMP +); + +SHOW CREATE TABLE tb01; + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f8, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'Text1', x'65', 123.456, 7.89, 12.34, 1, 100, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f8, f9, f10, f11, f12, f13, f14, f15) +VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + +select * from tb01 order by f1; + +CREATE TABLE tb02 ( + f1 VARCHAR(200) not null , + f2 CHAR(20) not null , + f3 VARBINARY not null , + f4 DECIMAL(10, 3) not null , + f5 REAL not null , + f6 DOUBLE not null , + f8 TINYINT not null , + f9 SMALLINT not null , + f10 INT not null , + f11 INTEGER not null , + f12 BIGINT not null , + f13 DATE not null , + f14 TIME not null , + f15 TIMESTAMP not null +); + +show create table tb02; + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f8, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'Text1', x'65', 123.456, 7.89, 12.34, 1, 100, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f8, f9, f10, f11, f12, f13, f14, f15) +VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f8, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', NULL, x'65', 123.456, 7.89, 12.34, 1, 100, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f8, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'same3', x'65', 123.456, 7.89, 12.34, 1, 100, 1000, 1000, NULl, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f8, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'same9', x'65', 123.456, 7.89, 12.34, 1, 100, 1000, 1000, 1992382342, DATE '2024-01-01', NULL, TIMESTAMP '2024-01-01 08:00:00'); + +drop table tb01; + +drop table tb02; + +drop schema "test.gt_mysql".gt_db1 cascade; diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.txt new file mode 100644 index 00000000000..d2629bda0d5 --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00006_datatype.txt @@ -0,0 +1,72 @@ +CREATE SCHEMA + +USE + +CREATE TABLE + +"CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( + f1 varchar(200), + f2 char(20), + f3 varbinary, + f4 decimal(10, 3), + f5 real, + f6 double, + f8 tinyint, + f9 smallint, + f10 integer, + f11 integer, + f12 bigint, + f13 date, + f14 time(3), + f15 timestamp(3) +) +COMMENT '' +WITH ( + engine = 'InnoDB' +)" + +INSERT: 1 row + +INSERT: 1 row + +"Sample text 1","Text1 ","65","123.456","7.89","12.34","1","100","1000","1000","100000","2024-01-01","08:00:00.000","2024-01-01 08:00:00.000" +"","","","","","","","","","","","","","" + +CREATE TABLE + +"CREATE TABLE ""test.gt_mysql"".gt_db1.tb02 ( + f1 varchar(200) NOT NULL, + f2 char(20) NOT NULL, + f3 varbinary NOT NULL, + f4 decimal(10, 3) NOT NULL, + f5 real NOT NULL, + f6 double NOT NULL, + f8 tinyint NOT NULL, + f9 smallint NOT NULL, + f10 integer NOT NULL, + f11 integer NOT NULL, + f12 bigint NOT NULL, + f13 date NOT NULL, + f14 time(3) NOT NULL, + f15 timestamp(3) NOT NULL +) +COMMENT '' +WITH ( + engine = 'InnoDB' +)" + +INSERT: 1 row + + NULL value not allowed for NOT NULL column: f1 + + NULL value not allowed for NOT NULL column: f2 + + NULL value not allowed for NOT NULL column: f12 + + NULL value not allowed for NOT NULL column: f14 + +DROP TABLE + +DROP TABLE + +DROP SCHEMA diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00004_query_pushdown.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00004_query_pushdown.txt index 6dbdd430217..348492934c1 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00004_query_pushdown.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00004_query_pushdown.txt @@ -40,8 +40,7 @@ INSERT: 15000 rows "Trino version: % % - TableScan[table = test.gt_postgresql:Query[SELECT l.""orderkey"" AS ""orderkey_0"", l.""custkey"" AS ""custkey_1"", r.""custkey"" AS ""custkey_2"" FROM (SELECT ""orderkey"", ""custkey"" FROM ""gt_db1"".""orders"") l INNER JOIN (SELECT ""custkey"" FROM ""gt_db1"".""customer"") r ON l.""custkey"" = r.""custkey""] sortOrder=[orderkey_0:bigint:int8 ASC NULLS LAST] limit=10 columns=[orderkey_0:bigint:int8, custkey_2:bigint:int8]] - Layout: [orderkey:bigint, custkey:bigint] + TableScan[table = test.gt_postgresql:Query[SELECT % INNER JOIN %] limit=10 columns=%] % " diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.sql new file mode 100644 index 00000000000..d67997d2b8c --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.sql @@ -0,0 +1,72 @@ +CREATE SCHEMA "test.gt_postgresql".gt_db1; + +USE "test.gt_postgresql".gt_db1; + +-- Unsupported Type: TINYINT +CREATE TABLE tb01 ( + f1 VARCHAR(200), + f2 CHAR(20), + f3 VARBINARY, + f4 DECIMAL(10, 3), + f5 REAL, + f6 DOUBLE, + f7 BOOLEAN, + f9 SMALLINT, + f10 INT, + f11 INTEGER, + f12 BIGINT, + f13 DATE, + f14 TIME, + f15 TIMESTAMP +); + + +SHOW CREATE TABLE tb01; + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f7, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'Text1', x'65', 123.456, 7.89, 12.34, false, 100, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f7, f9, f10, f11, f12, f13, f14, f15) +VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + +select * from tb01 order by f1; + +CREATE TABLE tb02 ( + f1 VARCHAR(200) not null , + f2 CHAR(20) not null , + f3 VARBINARY not null , + f4 DECIMAL(10, 3) not null , + f5 REAL not null , + f6 DOUBLE not null , + f7 BOOLEAN not null , + f9 SMALLINT not null , + f10 INT not null , + f11 INTEGER not null , + f12 BIGINT not null , + f13 DATE not null , + f14 TIME not null , + f15 TIMESTAMP not null +); + +show create table tb02; + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'Text1', x'65', 123.456, 7.89, 12.34, false, 100, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f9, f10, f11, f12, f13, f14, f15) +VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', NULL, x'65', 123.456, 7.89, 12.34, false, 100, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'same3', x'65', 123.456, 7.89, 12.34, false, 100, 1000, 1000, NULl, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f9, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'same9', x'65', 123.456, 7.89, 12.34, false, 100, 1000, 1000, 1992382342, DATE '2024-01-01', NULL, TIMESTAMP '2024-01-01 08:00:00'); + +drop table tb01; + +drop table tb02; + +drop schema "test.gt_postgresql".gt_db1 cascade; diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.txt new file mode 100644 index 00000000000..56ebe5d87c9 --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-postgresql/00006_datatype.txt @@ -0,0 +1,66 @@ +CREATE SCHEMA + +USE + +CREATE TABLE + +"CREATE TABLE ""test.gt_postgresql"".gt_db1.tb01 ( + f1 varchar, + f2 varchar, + f3 varbinary, + f4 decimal(10, 3), + f5 real, + f6 double, + f7 boolean, + f9 smallint, + f10 integer, + f11 integer, + f12 bigint, + f13 date, + f14 time(3), + f15 timestamp(3) +) +COMMENT ''" + +INSERT: 1 row + +INSERT: 1 row + +"Sample text 1","Text1","65","123.456","7.89","12.34","false","100","1000","1000","100000","2024-01-01","08:00:00.000","2024-01-01 08:00:00.000" +"","","","","","","","","","","","","","" + +CREATE TABLE + +"CREATE TABLE ""test.gt_postgresql"".gt_db1.tb02 ( + f1 varchar NOT NULL, + f2 varchar NOT NULL, + f3 varbinary NOT NULL, + f4 decimal(10, 3) NOT NULL, + f5 real NOT NULL, + f6 double NOT NULL, + f7 boolean NOT NULL, + f9 smallint NOT NULL, + f10 integer NOT NULL, + f11 integer NOT NULL, + f12 bigint NOT NULL, + f13 date NOT NULL, + f14 time(3) NOT NULL, + f15 timestamp(3) NOT NULL +) +COMMENT ''" + +INSERT: 1 row + + NULL value not allowed for NOT NULL column: f1 + + NULL value not allowed for NOT NULL column: f2 + + NULL value not allowed for NOT NULL column: f12 + + NULL value not allowed for NOT NULL column: f14 + +DROP TABLE + +DROP TABLE + +DROP SCHEMA diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00001_select_table.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00001_select_table.txt index f5aa32125e3..e9d4da0dadb 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00001_select_table.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00001_select_table.txt @@ -27,5 +27,3 @@ DROP TABLE DROP TABLE DROP SCHEMA - - diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.sql new file mode 100644 index 00000000000..8e6e4f95a77 --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.sql @@ -0,0 +1,69 @@ +CREATE SCHEMA "test.gt_iceberg".gt_db2; + +USE "test.gt_iceberg".gt_db2; + +-- Unsupported Type: TINYINT, SMALLINT +CREATE TABLE tb01 ( + f1 VARCHAR(200), + f2 CHAR(20), + f3 VARBINARY, + f4 DECIMAL(10, 3), + f5 REAL, + f6 DOUBLE, + f7 BOOLEAN, + f10 INT, + f11 INTEGER, + f12 BIGINT, + f13 DATE, + f14 TIME, + f15 TIMESTAMP +); + +SHOW CREATE TABLE tb01; + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f7, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'Text1', x'65', 123.456, 7.89, 12.34, true, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb01 (f1, f2, f3, f4, f5, f6, f7, f10, f11, f12, f13, f14, f15) +VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + +select * from tb01 order by f1; + +CREATE TABLE tb02 ( + f1 VARCHAR(200) not null , + f2 CHAR(20) not null , + f3 VARBINARY not null , + f4 DECIMAL(10, 3) not null , + f5 REAL not null , + f6 DOUBLE not null , + f7 BOOLEAN not null , + f10 INT not null , + f11 INTEGER not null , + f12 BIGINT not null , + f13 DATE not null , + f14 TIME not null , + f15 TIMESTAMP not null +); + +show create table tb02; + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'Text1', x'65', 123.456, 7.89, 12.34, true, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f10, f11, f12, f13, f14, f15) +VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', NULL, x'65', 123.456, 7.89, 12.34, true, 1000, 1000, 100000, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'same3', x'65', 123.456, 7.89, 12.34, true, 1000, 1000, NULl, DATE '2024-01-01', TIME '08:00:00', TIMESTAMP '2024-01-01 08:00:00'); + +INSERT INTO tb02 (f1, f2, f3, f4, f5, f6, f7, f10, f11, f12, f13, f14, f15) +VALUES ('Sample text 1', 'same9', x'65', 123.456, 7.89, 12.34, true, 1000, 1000, 1992382342, DATE '2024-01-01', NULL, TIMESTAMP '2024-01-01 08:00:00'); + +drop table tb01; + +drop table tb02; + +drop schema "test.gt_iceberg".gt_db2; diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.txt new file mode 100644 index 00000000000..aa6b6901c5d --- /dev/null +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/lakehouse-iceberg/00006_datatype.txt @@ -0,0 +1,65 @@ +CREATE SCHEMA + +USE + +CREATE TABLE + +"CREATE TABLE ""test.gt_iceberg"".gt_db2.tb01 ( + f1 varchar, + f2 varchar, + f3 varbinary, + f4 decimal(10, 3), + f5 real, + f6 double, + f7 boolean, + f10 integer, + f11 integer, + f12 bigint, + f13 date, + f14 time(3), + f15 timestamp(3) +) +COMMENT ''" + + +INSERT: 1 row + +INSERT: 1 row + +"Sample text 1","Text1","65","123.456","7.89","12.34","true","1000","1000","100000","2024-01-01","08:00:00.000","2024-01-01 08:00:00.000" +"","","","","","","","","","","","","" + +CREATE TABLE + +"CREATE TABLE ""test.gt_iceberg"".gt_db2.tb02 ( + f1 varchar NOT NULL, + f2 varchar NOT NULL, + f3 varbinary NOT NULL, + f4 decimal(10, 3) NOT NULL, + f5 real NOT NULL, + f6 double NOT NULL, + f7 boolean NOT NULL, + f10 integer NOT NULL, + f11 integer NOT NULL, + f12 bigint NOT NULL, + f13 date NOT NULL, + f14 time(3) NOT NULL, + f15 timestamp(3) NOT NULL +) +COMMENT ''" + +INSERT: 1 row + + NULL value not allowed for NOT NULL column: f1 + + NULL value not allowed for NOT NULL column: f2 + + NULL value not allowed for NOT NULL column: f12 + + NULL value not allowed for NOT NULL column: f14 + +DROP TABLE + +DROP TABLE + +DROP SCHEMA diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/DummyGravitinoConnector.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/DummyGravitinoConnector.java index 57f32e35698..30c3237dd51 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/DummyGravitinoConnector.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/DummyGravitinoConnector.java @@ -58,7 +58,7 @@ public DummyGravitinoConnector(String metalake, CatalogConnectorManager catalogC new Procedure.Argument("PROVIDER", VARCHAR), new Procedure.Argument( "PROPERTIES", new MapType(VARCHAR, VARCHAR, new TypeOperators())), - new Procedure.Argument("IGNORE_EXIST", BOOLEAN, false, true)); + new Procedure.Argument("IGNORE_EXIST", BOOLEAN, false, false)); Procedure procedure = new Procedure("system", "create_catalog", arguments, createCatalog); procedures.add(procedure); @@ -72,7 +72,7 @@ public DummyGravitinoConnector(String metalake, CatalogConnectorManager catalogC arguments = List.of( new Procedure.Argument("CATALOG", VARCHAR), - new Procedure.Argument("IGNORE_NOT_EXIST", BOOLEAN, false, true)); + new Procedure.Argument("IGNORE_NOT_EXIST", BOOLEAN, false, false)); procedure = new Procedure("system", "drop_catalog", arguments, dropCatalog); procedures.add(procedure);