Skip to content

GH-51114: [FlightSQL][C++] Expose is_update field of PreparedStatement - #51133

Open
SHIVANSH-ux-ys wants to merge 6 commits into
apache:mainfrom
SHIVANSH-ux-ys:feature-51114-flightsql-is-update
Open

GH-51114: [FlightSQL][C++] Expose is_update field of PreparedStatement#51133
SHIVANSH-ux-ys wants to merge 6 commits into
apache:mainfrom
SHIVANSH-ux-ys:feature-51114-flightsql-is-update

Conversation

@SHIVANSH-ux-ys

@SHIVANSH-ux-ys SHIVANSH-ux-ys commented Sep 2, 2026

Copy link
Copy Markdown

Fixes #51114.

Exposes the is_update boolean field in the C++ Flight SQL layer:

  • Added is_update field to ActionCreatePreparedStatementResult in server.h and updated PackActionResult in server.cc.
  • Added bool is_update = false parameter and is_update() const accessor to PreparedStatement in client.h/client.cc.
  • Updated PreparedStatement::ParseResponse to extract is_update.
  • Updated SQLite example server (sqlite_server.cc) to populate is_update via sqlite3_stmt_readonly.
  • Added assertions in server_test.cc for both query (ASSERT_FALSE) and update (ASSERT_TRUE) prepared statements.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51114 has been automatically assigned in GitHub to PR creator.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51114 has no components, please add labels for components.

@lidavidm 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.

Seems reasonable, but please fix the PR title/description.

Also CC @ennuite. Was there an integration test case we can enable? (I don't see one.)

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Sep 2, 2026
@SHIVANSH-ux-ys SHIVANSH-ux-ys changed the title GH-51114: [FlightSQL][C++] Expose is_update field of PreparedStatemen… GH-51114: [FlightSQL][C++] Expose is_update field of PreparedStatement Sep 2, 2026
@SHIVANSH-ux-ys

Copy link
Copy Markdown
Author

Thanks @lidavidm! Updated the PR title and description.

Also added support to populate is_update in the SQLite example server (sqlite_server.cc) using sqlite3_stmt_readonly and added integration test assertions in server_test.cc for both TestCommandPreparedStatementQuery (ASSERT_FALSE) and TestCommandPreparedStatementUpdate (ASSERT_TRUE). CC @ennuite

@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51114 has been automatically assigned in GitHub to PR creator.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51114 has no components, please add labels for components.

@ennuite ennuite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I will do a deeper review tomorrow as I'm still familiarizing myself with the C++ codebase.

However, I don't see the same semantics as other PRs here. We need more than is_update being true/false, we need a presence check to know if the field was ever sent. This is important for backward compatibility (I assume most servers will not send this field).

The updates done to the tests also seem to not leave any test that doesn't set the field. IMO this is the most important test (again for backward compatibility).

@SHIVANSH-ux-ys I would like to preserve the true/false/unset semantics if possible.

@ennuite

ennuite commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the cc @lidavidm

@SHIVANSH-ux-ys

Copy link
Copy Markdown
Author

Updated with the Doxygen parameter docstring for is_update in client.h. Ready for review / workflow approval when convenient @lidavidm @ennuite!

@ennuite ennuite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@SHIVANSH-ux-ys I don't understand how the Doxygen comment is related to the requested changes.

is_update is an optional field, I don't see this represented in the code.

Let me know if you need extra guidance.

@SHIVANSH-ux-ys

Copy link
Copy Markdown
Author

Thanks for the feedback @ennuite! Updated PreparedStatement::is_update() to return std::optional<bool> (std::nullopt when unset on the protobuf response, matching optional field semantics). Ready for review!

@ennuite ennuite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the changes @SHIVANSH-ux-ys, it's looking better!

A few things that still weren't addressed from my initial review:

  1. There is no test that covers the case where the server doesn't set the new field. As I mentioned, this is the most critical test for backwards compatibility, as most servers won't implement the protocol change once it is released.
  2. On the server side, the current implementation always sets the flag. I'm not sure that this is the intended behavior: given that the field is optional, servers should be allowed to not set it.

…atement

Signed-off-by: SHIVANSH-ux-ys <singaser78@gmail.com>
@SHIVANSH-ux-ys
SHIVANSH-ux-ys force-pushed the feature-51114-flightsql-is-update branch from 326db49 to 8f4de17 Compare September 5, 2026 02:18
@SHIVANSH-ux-ys

Copy link
Copy Markdown
Author

Thanks for the thorough review @ennuite! Addressed both items from your review:

  1. Server-side Optionality: Updated ActionCreatePreparedStatementResult::is_update in server.h to std::optional<bool> is_update = std::nullopt; so servers are allowed to leave the field unset, and PackActionResult in server.cc only populates the field when present.
  2. Backwards Compatibility Test: Added unit test TestCommandPreparedStatementUnsetIsUpdate in server_test.cc verifying that an unset is_update field is omitted from the serialized result and evaluates to std::nullopt on the client.

Ready for re-review!

@ennuite ennuite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@SHIVANSH-ux-ys the commit you made does not contain the changes you said it had.

…sult::is_update optional and add unit test for unset case

Signed-off-by: SHIVANSH-ux-ys <singaser78@gmail.com>
@SHIVANSH-ux-ys

Copy link
Copy Markdown
Author

Apologies @ennuite! The local commit with ActionCreatePreparedStatementResult::is_update optionality (std::optional<bool>) and TestCommandPreparedStatementUnsetIsUpdate unit test was committed locally but had not been pushed. Just pushed commit 4bd26bd with the complete changes. Thanks for catching that!

@ennuite ennuite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @SHIVANSH-ux-ys
The direction taken with the implementation LGTM, but the test has serious problems. It doesn't even seem to compile.

I strongly encourage you to take a look at
https://arrow.apache.org/docs/developers/overview.html#ai-generated-code and ensure that you are following the guidelines if you are using AI for contributing.

Given that this is your first PR in the Arrow community, I understand this might be a lot to take in.

Can you describe in your own words what we are trying to accomplish with these tests, and how they fit in with the protocol change? Were you able to take a look at the Arrow-Go PR before starting your own?

…ult unset test compilation

Signed-off-by: SHIVANSH-ux-ys <singaser78@gmail.com>
@SHIVANSH-ux-ys

Copy link
Copy Markdown
Author

Hi @ennuite!

Thanks for the feedback and guidance!

To answer your questions directly:

  1. Goal of these tests & protocol alignment:
    The Flight SQL protocol update adds an optional is_update boolean field (ARROW-15: Fix a naming typo for memory.AllocationManager.AllocationOutcome #4) to ActionCreatePreparedStatementResult. Because existing servers deployed in the wild will not populate this field, the client must treat it as optional (std::optional<bool>) rather than assuming a default false.

    The unit tests verify:

    • For query prepared statements (SELECT), is_update() returns std::optional<bool>(false).
    • For modification prepared statements (INSERT/UPDATE), is_update() returns std::optional<bool>(true).
    • For backwards compatibility, when a server leaves is_update unset (or for custom/legacy servers), ActionCreatePreparedStatementResult::is_update is std::nullopt, omitted from serialization, and PreparedStatement::is_update() evaluates to std::nullopt.

    I just pushed commit fb2cd35 which cleans up the unit test in server_test.cc (TestCommandPreparedStatementUnsetIsUpdate) so it compiles cleanly and directly verifies this unset behavior.

  2. Arrow-Go PR reference:
    Yes! The Go Flight SQL client (ci: add self-assignable issues arrow-go#176 / [C++][Compute] Invalid memory access when resizing row table #43414) represents this via (bool, bool) / optional semantics to distinguish between "field not provided by server" vs "explicitly set". This C++ PR brings the C++ FlightSqlClient API to parity with that same protocol specification.

Appreciate your guidance on my first C++ Flight SQL contribution! Ready for re-review whenever convenient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FlightSQL][C++] Expose is_update field of PreparedStatement

3 participants