Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] Exception with Postgres join in playground #1154

Closed
justinmclean opened this issue Dec 14, 2023 · 4 comments · Fixed by #1177
Closed

[Bug report] Exception with Postgres join in playground #1154

justinmclean opened this issue Dec 14, 2023 · 4 comments · Fixed by #1177
Assignees

Comments

@justinmclean
Copy link
Member

Describe what's wrong

An exception is thrown when trying to join two tables in Postgres from a Trino connection in dbeaver.

Error message and/or stacktrace

org.jkiss.dbeaver.model.exec.DBCException: SQL Error [65536]: Query failed (#20231214_062414_00043_prk8b): java.lang.ClassCastException: Cannot cast com.datastrato.gravitino.trino.connector.GravitinoColumnHandle to io.trino.plugin.jdbc.JdbcColumnHandle
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetImpl.nextRow(JDBCResultSetImpl.java:183)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.fetchQueryData(SQLQueryJob.java:874)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:657)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$1(SQLQueryJob.java:510)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:190)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:517)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:971)
at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:4135)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:190)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5151)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.sql.SQLException: Query failed (#20231214_062414_00043_prk8b): java.lang.ClassCastException: Cannot cast com.datastrato.gravitino.trino.connector.GravitinoColumnHandle to io.trino.plugin.jdbc.JdbcColumnHandle
at io.trino.jdbc.AbstractTrinoResultSet.resultsException(AbstractTrinoResultSet.java:1937)
at io.trino.jdbc.TrinoResultSet$ResultsPageIterator.computeNext(TrinoResultSet.java:294)
at io.trino.jdbc.TrinoResultSet$ResultsPageIterator.computeNext(TrinoResultSet.java:254)
at io.trino.jdbc.$internal.guava.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)
at io.trino.jdbc.$internal.guava.collect.AbstractIterator.hasNext(AbstractIterator.java:140)
at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Unknown Source)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(Unknown Source)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(Unknown Source)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(Unknown Source)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(Unknown Source)
at java.base/java.util.Spliterators$1Adapter.hasNext(Unknown Source)
at io.trino.jdbc.TrinoResultSet$AsyncIterator.lambda$new$1(TrinoResultSet.java:179)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.util.concurrent.CompletionException: java.lang.ClassCastException: Cannot cast com.datastrato.gravitino.trino.connector.GravitinoColumnHandle to io.trino.plugin.jdbc.JdbcColumnHandle
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:687)
at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:662)
at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2168)
at io.trino.plugin.jdbc.DynamicFilteringJdbcSplitSource.getNextBatch(DynamicFilteringJdbcSplitSource.java:57)
at io.trino.plugin.jdbc.JdbcDynamicFilteringSplitManager$DynamicFilteringSplitSource.getNextBatch(JdbcDynamicFilteringSplitManager.java:140)
at io.trino.split.ConnectorAwareSplitSource.getNextBatch(ConnectorAwareSplitSource.java:53)
at io.trino.split.TracingSplitSource.getNextBatch(TracingSplitSource.java:63)
at io.trino.split.BufferingSplitSource$GetNextBatch.fetchSplits(BufferingSplitSource.java:109)
at io.trino.split.BufferingSplitSource$GetNextBatch.lambda$fetchSplits$1(BufferingSplitSource.java:117)
at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:223)
at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:210)
at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:123)
at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1286)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1055)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:782)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.setResult(AbstractTransformFuture.java:257)
at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:169)
at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1286)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1055)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:782)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:49)
at io.airlift.concurrent.MoreFutures.lambda$toListenableFuture$11(MoreFutures.java:515)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
at io.airlift.concurrent.MoreFutures$UnmodifiableCompletableFuture.internalComplete(MoreFutures.java:648)
at io.airlift.concurrent.MoreFutures.lambda$unmodifiableFuture$2(MoreFutures.java:150)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
at io.airlift.concurrent.MoreFutures$2.onSuccess(MoreFutures.java:487)
at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1133)
at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1286)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1055)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:782)
at io.airlift.concurrent.ExtendedSettableFuture.set(ExtendedSettableFuture.java:26)
at io.airlift.concurrent.ExtendedSettableFuture.lambda$setAsync$0(ExtendedSettableFuture.java:54)
at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1286)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1055)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:782)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:49)
at io.trino.server.DynamicFilterService$DynamicFilterContext.lambda$new$1(DynamicFilterService.java:932)
at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1286)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1055)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:782)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:49)
at io.trino.server.DynamicFilterService$DynamicFilterCollectionContext.setExpectedTaskCount(DynamicFilterService.java:883)
at io.trino.server.DynamicFilterService$DynamicFilterContext.lambda$updateExpectedTaskCount$5(DynamicFilterService.java:997)
at java.base/java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1603)
at io.trino.server.DynamicFilterService$DynamicFilterContext.updateExpectedTaskCount(DynamicFilterService.java:991)
at io.trino.server.DynamicFilterService$DynamicFilterContext.addTaskDynamicFilters(DynamicFilterService.java:978)
at io.trino.server.DynamicFilterService.addTaskDynamicFilters(DynamicFilterService.java:400)
at io.trino.server.remotetask.DynamicFiltersFetcher.updateDynamicFilterDomains(DynamicFiltersFetcher.java:224)
at io.trino.server.remotetask.DynamicFiltersFetcher$DynamicFiltersResponseCallback.success(DynamicFiltersFetcher.java:168)
at io.trino.server.remotetask.DynamicFiltersFetcher$DynamicFiltersResponseCallback.success(DynamicFiltersFetcher.java:157)
at io.trino.server.remotetask.SimpleHttpResponseHandler.onSuccess(SimpleHttpResponseHandler.java:49)
at io.trino.server.remotetask.SimpleHttpResponseHandler.onSuccess(SimpleHttpResponseHandler.java:27)
at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1133)
at io.airlift.concurrent.BoundedExecutor.drainQueue(BoundedExecutor.java:79)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassCastException: Cannot cast com.datastrato.gravitino.trino.connector.GravitinoColumnHandle to io.trino.plugin.jdbc.JdbcColumnHandle
at java.base/java.lang.Class.cast(Class.java:3889)
at io.trino.spi.predicate.TupleDomain.transformKeys(TupleDomain.java:545)
at io.trino.plugin.jdbc.DynamicFilteringJdbcSplitSource.lambda$getNextBatch$1(DynamicFilteringJdbcSplitSource.java:59)
at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:684)
... 68 more

How to reproduce

Run this query in a Trino connection in dbeaver.

select *
from "metalake_demo.catalog_pg1".hr.employees e, "metalake_demo.catalog_pg1".hr.employee_performance ep
where e.employee_id = ep.employee_id

Additional context

No response

@jerryshao
Copy link
Contributor

@diqiu50 would you please take a look?

@diqiu50
Copy link
Contributor

diqiu50 commented Dec 14, 2023

It's a bug. we can run this sql to avoid it in the current version.
set session allow_pushdown_into_connectors=false;

@justinmclean
Copy link
Member Author

The same happens on AWS so it is not just restricted to the playground.

@justinmclean
Copy link
Member Author

can confirm that this gets around the issue.
set session allow_pushdown_into_connectors=false;

I can see this is in one example but is not explained or mentioned in the documentation.

@diqiu50 diqiu50 self-assigned this Dec 15, 2023
diqiu50 added a commit that referenced this issue Dec 18, 2023
… 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
github-actions bot pushed a commit that referenced this issue Dec 18, 2023
… 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
jerryshao pushed a commit that referenced this issue Dec 18, 2023
… in PostgreSQL. (#1186)

### 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

Co-authored-by: Yuhui <hui@datastrato.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants