FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-797: [JDBC] Fix PreparedStatement#execute for DML/DDL by ennuite · Pull Request #811 · apache/arrow-java · GitHub

GH-797: [JDBC] Fix PreparedStatement#execute for DML/DDL - #811

Merged
lidavidm merged 2 commits into
apache:mainfrom
ennuite:GH-797
Aug 20, 2025
Merged

GH-797: [JDBC] Fix PreparedStatement#execute for DML/DDL#811
lidavidm merged 2 commits into
apache:mainfrom
ennuite:GH-797

Conversation

ennuite commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

What's Changed

Instead of always obtaining a result set for queries issued via
PreparedStatement.execute(), we now inspect the dataset_schema
returned in ActionCreatePreparedStatementResult. If the schema has no
fields, we retrieve the update count instead. This aligns the return
value with the expectations of the JDBC API.

For such cases, the Arrow Flight SQL path now uses
CommandPreparedStatementUpdate instead of
CommandPreparedStatementQuery. This change mirrors the existing
approach in Statement.execute() and Statement.executeUpdate().

Are these changes tested?

Yes

Closes #797.

ennuite added 2 commits August 7, 2025 00:25
What's Changed

Instead of always obtaining a result set for queries issued via
PreparedStatement.execute(), we now inspect the dataset_schema
returned in ActionCreatePreparedStatementResult. If the schema has no
fields, we retrieve the update count instead. This aligns the return
value with the expectations of the JDBC API.

For such cases, the Arrow Flight SQL path now uses
CommandPreparedStatementUpdate instead of
CommandPreparedStatementQuery. This change mirrors the existing
approach in Statement.execute() and Statement.executeUpdate().
ennuite marked this pull request as ready for review August 7, 2025 09:01
lidavidm changed the title GH-797: [JDBC] Fix pstmt.execute() for DML/DDL GH-797: [JDBC] Fix PreparedStatement#execute for DML/DDL Aug 7, 2025

lidavidm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, this looks reasonable to me.

lidavidm commented Aug 7, 2025

Copy link
Copy Markdown
Member

@alamb @jbonofre do InfluxDB and Dremio satisfy the assumptions here (dataset_schema will be populated if and only if the query of a prepared statement returns a result set)? I'm wondering if there might be systems that don't analyze the query at first and always omit the schema until actual execution

(We should really try to set up integration testing with Dremio and InfluxDB...)

alamb commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

@alamb @jbonofre do InfluxDB and Dremio satisfy the assumptions here (dataset_schema will be populated if and only if the query of a prepared statement returns a result set)? I'm wondering if there might be systems that don't analyze the query at first and always omit the schema until actual execution

Yes.

However, I think all our queries return results (InfluxDB doesn't do DDL / DML using SQL -- there is an alternate write path) so this particular issue is unlikely to affect us

Our system will actually analyze / plan the query twice -- once on the prepare and once when executing. While this is somewhat wasteful it allows us to remain stateless between requests

ennuite commented Aug 20, 2025

Copy link
Copy Markdown
Contributor Author

@lidavidm Hello David. I currently work at Dremio. From our side we are ok with these changes.

lidavidm merged commit 156b465 into apache:main Aug 20, 2025
19 of 24 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PreparedStatement.execute() returns True for DML/DDL queries

3 participants


Back | FazBrowse Home | New Git URL