Skip to content

JDBC Client: fix Exception Handling Bug in TrinoResultSet #25725

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kilnamkim
Copy link

Description

When using the configuration setting hive.query-partition-filter-required=true in Trino's JDBC client, a SQLException is expected to be thrown when a query is missing a required partition column. However, no error was raised in this case.
The root cause is that when a query fails due to a missing partition filter, results.getColumns() returns an empty List object (i.e., a list with a size of 0). As a result, the exception handling logic that depends on the presence of columns was not triggered as expected.
This fix ensures that when the query execution result is FAILED, the column retrieval will also fail accordingly, allowing the exception handling code to run as intended.


Change Summary

  • Type: Bug fix
  • Impact Area: JDBC Client
  • User-facing Description: Fixes a bug in Trino JDBC where exception handling in TrinoResultSet was not triggered when a query failed due to missing partition filters.

…was not triggered when a query failed due to missing partition filters.
@cla-bot cla-bot bot added the cla-signed label May 3, 2025
@github-actions github-actions bot added the jdbc Relates to Trino JDBC driver label May 3, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reword the commit message as mentioned here https://trino.io/development/process#pull-request-and-commit-guidelines-

Comment on lines +134 to +136
private static class ExtraCredentialsSystemTable
implements SystemTable
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this System table ?


@TestInstance(PER_CLASS)
@Execution(CONCURRENT)
public class TestJdbcPartitionFilterRequired
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the issue is very specific to PartitionFilter for hive ? If it is a race condition then it should be seen by other connectors as well.


@TestInstance(PER_CLASS)
@Execution(CONCURRENT)
public class TestJdbcPartitionFilterRequired
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the guideline: Test classes should be defined as package-private and final.

}

@Test
public void testFilterRequiredPartitions()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the guideline: Test methods should be defined as package-private.

@@ -129,7 +129,7 @@ private static List<Column> getColumns(StatementClient client, Consumer<QuerySta
QueryStatusInfo results = client.currentStatusInfo();
progressCallback.accept(QueryStats.create(results.getId(), results.getStats()));
List<Column> columns = results.getColumns();
if (columns != null) {
if (columns != null && !results.getStats().getState().equals("FAILED")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how does this get empty columns? @wendigo
I think it's a bug that should fix in the place that return empty columns

ResultSet resultSet = statement.getResultSet();
assertThat(resultSet.next()).isTrue();
}
}).isInstanceOf(SQLException.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the error message ?

Copy link

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions bot added the stale label May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed jdbc Relates to Trino JDBC driver stale
Development

Successfully merging this pull request may close these issues.

3 participants