From 780e7db6553d217f02eca0f9a6dcc3635679bf52 Mon Sep 17 00:00:00 2001 From: yuhui Date: Fri, 15 Dec 2023 23:06:07 +0800 Subject: [PATCH] Fix the issue with joins causing errors in PostgreSQL. --- .../jdbc-postgresql/00003_join_pushdown.sql | 61 +++++++++++++++++++ .../jdbc-postgresql/00003_join_pushdown.txt | 28 +++++++++ .../connector/GravitinoSplitManager.java | 3 +- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.sql create mode 100644 integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.txt diff --git a/integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.sql b/integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.sql new file mode 100644 index 00000000000..46395154373 --- /dev/null +++ b/integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.sql @@ -0,0 +1,61 @@ +CREATE SCHEMA "test.jdbc-postgresql".gt_db1; + +use "test.jdbc-postgresql".gt_db1; + +CREATE TABLE "test.jdbc-postgresql".gt_db1.employee_performance ( + employee_id integer, + evaluation_date date, + rating integer +) +COMMENT 'comment'; + +CREATE TABLE "test.jdbc-postgresql".gt_db1.employees ( + employee_id integer, + department_id integer, + job_title varchar(100), + given_name varchar(100), + family_name varchar(100), + birth_date date, + hire_date date +) +COMMENT 'comment'; + +INSERT INTO "test.jdbc-postgresql".gt_db1.employee_performance (employee_id, evaluation_date, rating) VALUES +(1, DATE '2018-02-24', 4), +(1, DATE '2016-12-25', 7), +(1, DATE '2023-04-07', 4), +(3, DATE '2012-11-08', 7), +(3, DATE '2019-09-15', 2), +(3, DATE '2017-06-21', 8), +(3, DATE '2019-07-16', 4), +(3, DATE '2015-10-06', 4), +(3, DATE '2021-01-05', 6), +(3, DATE '2014-10-24', 4); + +INSERT INTO "test.jdbc-postgresql".gt_db1.employees (employee_id, department_id, job_title, given_name, family_name, birth_date, hire_date) VALUES +(1, 1, 'Manager', 'Gregory', 'Smith', DATE '1968-04-15', DATE '2014-06-04'), +(2, 1, 'Sales Assistant', 'Owen', 'Rivers', DATE '1988-08-13', DATE '2021-02-05'), +(3, 1, 'Programmer', 'Avram', 'Lawrence', DATE '1969-11-21', DATE '2010-09-29'), +(4, 1, 'Sales Assistant', 'Burton', 'Everett', DATE '2001-12-07', DATE '2016-06-25'), +(5, 1, 'Sales Assistant', 'Cedric', 'Barlow', DATE '1972-02-02', DATE '2012-08-15'), +(6, 2, 'Sales Assistant', 'Jasper', 'Mack', DATE '2002-03-29', DATE '2020-09-13'), +(7, 1, 'Sales Assistant', 'Felicia', 'Robinson', DATE '1973-08-21', DATE '2023-05-14'), +(8, 3, 'Sales Assistant', 'Mason', 'Steele', DATE '1964-05-19', DATE '2019-02-06'), +(9, 3, 'Programmer', 'Bernard', 'Cameron', DATE '1995-08-27', DATE '2018-07-12'), +(10, 2, 'Programmer', 'Chelsea', 'Wade', DATE '2007-01-29', DATE '2016-04-16'); + +SELECT + given_name, + family_name, + rating +FROM "test.jdbc-postgresql".gt_db1.employee_performance AS p +JOIN "test.jdbc-postgresql".gt_db1.employees AS e + ON p.employee_id = e.employee_id +ORDER BY +rating DESC +LIMIT 10; + +drop table "test.jdbc-postgresql".gt_db1.employee_performance; +drop table "test.jdbc-postgresql".gt_db1.employees; + +drop schema "test.jdbc-postgresql".gt_db1; \ No newline at end of file diff --git a/integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.txt b/integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.txt new file mode 100644 index 00000000000..4b75b585b91 --- /dev/null +++ b/integration-test/src/test/resources/trino-queries/catalogs/jdbc-postgresql/00003_join_pushdown.txt @@ -0,0 +1,28 @@ +CREATE SCHEMA + +USE + +CREATE TABLE + +CREATE TABLE + +INSERT: 10 rows + +INSERT: 10 rows + +"Avram","Lawrence","8" +"Avram","Lawrence","7" +"Gregory","Smith","7" +"Avram","Lawrence","6" +"Avram","Lawrence","4" +"Avram","Lawrence","4" +"Gregory","Smith","4" +"Gregory","Smith","4" +"Avram","Lawrence","4" +"Avram","Lawrence","2" + +DROP TABLE + +DROP TABLE + +DROP SCHEMA \ No newline at end of file diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoSplitManager.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoSplitManager.java index 2468ad5b78b..ef7532b2f8f 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoSplitManager.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoSplitManager.java @@ -30,11 +30,12 @@ public ConnectorSplitSource getSplits( GravitinoTransactionHandle gravitinoTransactionHandle = (GravitinoTransactionHandle) transaction; + // TODO(yuhui) add dynamic filter return internalSplitManager.getSplits( gravitinoTransactionHandle.getInternalTransactionHandle(), session, gravitinoTableHandle.getInternalTableHandle(), - dynamicFilter, + DynamicFilter.EMPTY, constraint); } }