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 c7122622ac3 [test](trino connector) add trino connector query jdbc
datasource test (#50351)
c7122622ac3 is described below
commit c7122622ac3e77bc6943195ff39ad92016340de7
Author: zy-kkk <[email protected]>
AuthorDate: Tue May 13 12:38:25 2025 +0800
[test](trino connector) add trino connector query jdbc datasource test
(#50351)
---
.../TrinoConnectorExternalTable.java | 8 +-
.../trino_connector/jdbc/test_trino_clickhouse.out | Bin 0 -> 2971 bytes
.../trino_connector/jdbc/test_trino_mysql.out | Bin 0 -> 93532 bytes
.../trino_connector/jdbc/test_trino_oracle.out | Bin 0 -> 6046 bytes
.../trino_connector/jdbc/test_trino_pg.out | Bin 0 -> 1934 bytes
.../trino_connector/jdbc/test_trino_sqlserver.out | Bin 0 -> 3560 bytes
.../jdbc/test_trino_clickhouse.groovy | 57 ++++++++++++++
.../trino_connector/jdbc/test_trino_mysql.groovy | 64 +++++++++++++++
.../trino_connector/jdbc/test_trino_oracle.groovy | 57 ++++++++++++++
.../trino_connector/jdbc/test_trino_pg.groovy | 87 +++++++++++++++++++++
.../jdbc/test_trino_sqlserver.groovy | 57 ++++++++++++++
11 files changed, 328 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/trinoconnector/TrinoConnectorExternalTable.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/trinoconnector/TrinoConnectorExternalTable.java
index a664d388924..20e82d0b537 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/trinoconnector/TrinoConnectorExternalTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/trinoconnector/TrinoConnectorExternalTable.java
@@ -195,10 +195,10 @@ public class TrinoConnectorExternalTable extends
ExternalTable {
return ScalarType.createDateV2Type();
} else if (type instanceof TimestampType) {
TimestampType timestampType = (TimestampType) type;
- return
ScalarType.createDatetimeV2Type(timestampType.getPrecision());
+ return
ScalarType.createDatetimeV2Type(getMaxDatetimePrecision(timestampType.getPrecision()));
} else if (type instanceof TimestampWithTimeZoneType) {
TimestampWithTimeZoneType timestampWithTimeZoneType =
(TimestampWithTimeZoneType) type;
- return
ScalarType.createDatetimeV2Type(timestampWithTimeZoneType.getPrecision());
+ return
ScalarType.createDatetimeV2Type(getMaxDatetimePrecision(timestampWithTimeZoneType.getPrecision()));
} else if (type instanceof io.trino.spi.type.ArrayType) {
Type elementType = trinoConnectorTypeToDorisType(
((io.trino.spi.type.ArrayType) type).getElementType());
@@ -225,6 +225,10 @@ public class TrinoConnectorExternalTable extends
ExternalTable {
}
}
+ private int getMaxDatetimePrecision(int precision) {
+ return Math.min(precision, 6);
+ }
+
public ConnectorTableHandle getConnectorTableHandle() {
makeSureInitialized();
Optional<SchemaCacheValue> schemaCacheValue = getSchemaCacheValue();
diff --git
a/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_clickhouse.out
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_clickhouse.out
new file mode 100644
index 00000000000..84afab5bf32
Binary files /dev/null and
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_clickhouse.out
differ
diff --git
a/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_mysql.out
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_mysql.out
new file mode 100644
index 00000000000..4e7dfa57df7
Binary files /dev/null and
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_mysql.out
differ
diff --git
a/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_oracle.out
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_oracle.out
new file mode 100644
index 00000000000..d089e2ecac3
Binary files /dev/null and
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_oracle.out
differ
diff --git
a/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_pg.out
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_pg.out
new file mode 100644
index 00000000000..a89af2e41fd
Binary files /dev/null and
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_pg.out
differ
diff --git
a/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_sqlserver.out
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_sqlserver.out
new file mode 100644
index 00000000000..a6580c27051
Binary files /dev/null and
b/regression-test/data/external_table_p0/trino_connector/jdbc/test_trino_sqlserver.out
differ
diff --git
a/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_clickhouse.groovy
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_clickhouse.groovy
new file mode 100644
index 00000000000..8344a739252
--- /dev/null
+++
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_clickhouse.groovy
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_trino_clickhouse",
"p0,external,clickhouse,external_docker,external_docker_clickhouse") {
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ String enabled_trino_connector =
context.config.otherConfigs.get("enableTrinoConnectorTest")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ if (enabled != null && enabled.equalsIgnoreCase("true")
+ && enabled_trino_connector!= null &&
enabled_trino_connector.equalsIgnoreCase("true")) {
+
+ def host_ips = new ArrayList()
+ String[][] backends = sql """ show backends """
+ for (def b in backends) {
+ host_ips.add(b[1])
+ }
+ String [][] frontends = sql """ show frontends """
+ for (def f in frontends) {
+ host_ips.add(f[1])
+ }
+ dispatchTrinoConnectors(host_ips.unique())
+
+ String clickhouse_port =
context.config.otherConfigs.get("clickhouse_22_port");
+
+ sql """drop catalog if exists trino_clickhouse_test """
+ sql """create catalog if not exists trino_clickhouse_test properties(
+ "type"="trino-connector",
+ "trino.connector.name" = "clickhouse",
+ "trino.connection-user" = "default",
+ "trino.connection-url" =
"jdbc:clickhouse://${externalEnvIp}:${clickhouse_port}",
+ "trino.connection-password" = "123456",
+ "trino.jdbc-types-mapped-to-varchar" =
"UUID,Nullable(UUID),Ipv4,Nullable(Ipv4),Ipv6,Nullable(Ipv6)"
+ );"""
+
+ sql """use trino_clickhouse_test.doris_test"""
+
+ qt_desc_all_types_null """desc doris_test.extreme_test;"""
+ qt_select_all_types_null """select * from doris_test.extreme_test
order by 1;"""
+
+ qt_select_all_types_multi_block """select count(*) from
doris_test.extreme_test_multi_block;"""
+
+ sql """drop catalog if exists trino_clickhouse_test """
+ }
+}
diff --git
a/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_mysql.groovy
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_mysql.groovy
new file mode 100644
index 00000000000..c064304b7b6
--- /dev/null
+++
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_mysql.groovy
@@ -0,0 +1,64 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_trino_mysql",
"p0,external,mysql,external_docker,external_docker_mysql") {
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ String enabled_trino_connector =
context.config.otherConfigs.get("enableTrinoConnectorTest")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ if (enabled != null && enabled.equalsIgnoreCase("true")
+ && enabled_trino_connector!= null &&
enabled_trino_connector.equalsIgnoreCase("true")) {
+
+ def host_ips = new ArrayList()
+ String[][] backends = sql """ show backends """
+ for (def b in backends) {
+ host_ips.add(b[1])
+ }
+ String [][] frontends = sql """ show frontends """
+ for (def f in frontends) {
+ host_ips.add(f[1])
+ }
+ dispatchTrinoConnectors(host_ips.unique())
+
+ String mysql_port = context.config.otherConfigs.get("mysql_57_port");
+
+ sql """drop catalog if exists trino_mysql_test """
+ sql """create catalog if not exists trino_mysql_test properties(
+ "type"="trino-connector",
+ "trino.connector.name" = "mysql",
+ "trino.connection-user" = "root",
+ "trino.connection-url" =
"jdbc:mysql://${externalEnvIp}:${mysql_port}",
+ "trino.connection-password" = "123456",
+ "trino.jdbc-types-mapped-to-varchar" = "JSON"
+ );"""
+
+ sql """use trino_mysql_test.doris_test"""
+
+ qt_desc_all_types_null """desc all_types_nullable;"""
+ qt_select_all_types_null """select * except(time1,time2,time3) from
all_types_nullable order by 1;"""
+
+ qt_desc_all_types_non_null """desc all_types_non_nullable;"""
+ qt_select_all_types_non_null """select * except(time1,time2,time3)
from all_types_non_nullable order by 1;"""
+
+ qt_select_varchar """select * from t_varchar order by 1;"""
+ qt_select_char """select * from t_char order by 1;"""
+
+ qt_select_all_types_multi_block """select
count(`int`),count(`varchar`) from all_types_multi_block;"""
+
+ sql """drop catalog if exists trino_mysql_test """
+ }
+}
+
diff --git
a/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_oracle.groovy
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_oracle.groovy
new file mode 100644
index 00000000000..ed6e09e2429
--- /dev/null
+++
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_oracle.groovy
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_trino_oracle",
"p0,external,oracle,external_docker,external_docker_oracle") {
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ String enabled_trino_connector =
context.config.otherConfigs.get("enableTrinoConnectorTest")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ if (enabled != null && enabled.equalsIgnoreCase("true")
+ && enabled_trino_connector!= null &&
enabled_trino_connector.equalsIgnoreCase("true")) {
+
+ def host_ips = new ArrayList()
+ String[][] backends = sql """ show backends """
+ for (def b in backends) {
+ host_ips.add(b[1])
+ }
+ String [][] frontends = sql """ show frontends """
+ for (def f in frontends) {
+ host_ips.add(f[1])
+ }
+ dispatchTrinoConnectors(host_ips.unique())
+
+ String oracle_port = context.config.otherConfigs.get("oracle_11_port");
+ String SID = "XE";
+
+ sql """drop catalog if exists trino_oracle_test """
+ sql """create catalog if not exists trino_oracle_test properties(
+ "type"="trino-connector",
+ "trino.connector.name" = "oracle",
+ "trino.connection-user" = "doris_test",
+ "trino.connection-url" =
"jdbc:oracle:thin:@${externalEnvIp}:${oracle_port}:${SID}",
+ "trino.connection-password" = "123456"
+ );"""
+
+ sql """use trino_oracle_test.doris_test"""
+
+ qt_desc_all_types_null """desc doris_test.extreme_test;"""
+ qt_select_all_types_null """select * from doris_test.extreme_test
order by 1;"""
+
+ qt_select_all_types_multi_block """select count(*) from
doris_test.extreme_test_multi_block;"""
+
+ sql """drop catalog if exists trino_oracle_test """
+ }
+}
diff --git
a/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_pg.groovy
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_pg.groovy
new file mode 100644
index 00000000000..181243edde6
--- /dev/null
+++
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_pg.groovy
@@ -0,0 +1,87 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_trino_pg", "p0,external,pg,external_docker,external_docker_pg") {
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ String enabled_trino_connector =
context.config.otherConfigs.get("enableTrinoConnectorTest")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ if (enabled != null && enabled.equalsIgnoreCase("true")
+ && enabled_trino_connector!= null &&
enabled_trino_connector.equalsIgnoreCase("true")) {
+
+ def host_ips = new ArrayList()
+ String[][] backends = sql """ show backends """
+ for (def b in backends) {
+ host_ips.add(b[1])
+ }
+ String [][] frontends = sql """ show frontends """
+ for (def f in frontends) {
+ host_ips.add(f[1])
+ }
+ dispatchTrinoConnectors(host_ips.unique())
+
+ String pg_port = context.config.otherConfigs.get("pg_14_port");
+
+ sql """drop catalog if exists trino_pg_test """
+ sql """create catalog if not exists trino_pg_test properties(
+ "type"="trino-connector",
+ "trino.connector.name" = "postgresql",
+ "trino.connection-user" = "postgres",
+ "trino.connection-url" =
"jdbc:postgresql://${externalEnvIp}:${pg_port}/postgres?currentSchema=doris_test&useSSL=false",
+ "trino.connection-password" = "123456",
+ "trino.jdbc-types-mapped-to-varchar" =
"uuid,interval,inet,cidr,macaddr,point,line,circle,date,timestamp,timestamptz,json,jsonb"
+ );"""
+
+ sql """use trino_pg_test.catalog_pg_test"""
+
+ qt_desc_all_types_null """desc catalog_pg_test.extreme_test;"""
+
+ qt_select_all_types_null """SELECT
+ id,
+ smallint_val,
+ int_val,
+ bigint_val,
+ decimal_val,
+ real_val,
+ double_val,
+ char_val,
+ LENGTH(varchar_val) AS varchar_val_length,
+ LENGTH(text_val) AS text_val_length,
+ date_val,
+ timestamp_val,
+ timestamptz_val,
+ interval_val,
+ bool_val,
+ bytea_val,
+ inet_val,
+ cidr_val,
+ macaddr_val,
+ json_val,
+ jsonb_val,
+ point_val,
+ line_val,
+ circle_val,
+ uuid_val
+ FROM
+ catalog_pg_test.extreme_test
+ ORDER BY
+ 1;"""
+
+ qt_select_all_types_multi_block """select count(*) from
catalog_pg_test.extreme_test_multi_block;"""
+
+ sql """drop catalog if exists trino_pg_test """
+ }
+}
diff --git
a/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_sqlserver.groovy
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_sqlserver.groovy
new file mode 100644
index 00000000000..9973aaae2fb
--- /dev/null
+++
b/regression-test/suites/external_table_p0/trino_connector/jdbc/test_trino_sqlserver.groovy
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_trino_sqlserver",
"p0,external,sqlserver,external_docker,external_docker_sqlserver") {
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ String enabled_trino_connector =
context.config.otherConfigs.get("enableTrinoConnectorTest")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ if (enabled != null && enabled.equalsIgnoreCase("true")
+ && enabled_trino_connector!= null &&
enabled_trino_connector.equalsIgnoreCase("true")) {
+
+ def host_ips = new ArrayList()
+ String[][] backends = sql """ show backends """
+ for (def b in backends) {
+ host_ips.add(b[1])
+ }
+ String [][] frontends = sql """ show frontends """
+ for (def f in frontends) {
+ host_ips.add(f[1])
+ }
+ dispatchTrinoConnectors(host_ips.unique())
+
+ String sqlserver_port =
context.config.otherConfigs.get("sqlserver_2022_port");
+
+ sql """drop catalog if exists trino_sqlserver_test """
+ sql """create catalog if not exists trino_sqlserver_test properties(
+ "type"="trino-connector",
+ "trino.connector.name" = "sqlserver",
+ "trino.connection-user" = "sa",
+ "trino.connection-url" =
"jdbc:sqlserver://${externalEnvIp}:${sqlserver_port};encrypt=false;databaseName=doris_test;",
+ "trino.connection-password" = "Doris123456"
+ );"""
+
+ sql """use trino_sqlserver_test.dbo"""
+
+ qt_desc_all_types_null """desc dbo.extreme_test;"""
+
+ qt_select_all_types_null """select * from dbo.extreme_test order by
1;"""
+
+ qt_select_all_types_multi_block """select count(*) from
dbo.extreme_test_multi_block;"""
+
+ sql """drop catalog if exists trino_sqlserver_test """
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]