Skip to content

Commit

Permalink
[#1154] fix(trino-connector): Fix the issue with joins causing errors…
Browse files Browse the repository at this point in the history
… in PostgreSQL. (#1177)

### What changes were proposed in this pull request?

Fix the issue with joins causing errors in PostgreSQL.
Error message is "Cannot cast
com.datastrato.gravitino.trino.connector.GravitinoColumnHandle to
io.trino.plugin.jdbc.JdbcColumnHandle"

### Why are the changes needed?

Fix: #1154

### Does this PR introduce _any_ user-facing change?

NO

### How was this patch tested?

UT
  • Loading branch information
diqiu50 authored Dec 18, 2023
1 parent f3e1bae commit 20558b6
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 20558b6

Please sign in to comment.