Skip to content

test(arrow/flight/flightsql): add client tests for Substrait prepared statements - #1383

Merged
zeroshade merged 1 commit into
apache:mainfrom
sankalpsthakur:GH-1267-flightsql-substrait-client-tests
Oct 19, 2026
Merged

zeroshade merged 1 commit into
apache:mainfrom
sankalpsthakur:GH-1267-flightsql-substrait-client-tests

Conversation

@sankalpsthakur

Copy link
Copy Markdown
Contributor

Rationale for this change

#732 added server-side coverage for CreatePreparedSubstraitPlan, but the review on that PR noted that the client path (Client.PrepareSubstrait and Txn.PrepareSubstrait) had no dedicated tests. FlightSqlClientSuite only exercised SQL prepared statements, so a regression in how the Substrait action is built or how its result is parsed would go unnoticed.

What changes are included in this PR?

Four new cases in FlightSqlClientSuite in arrow/flight/flightsql/client_test.go, using the same mocked DoAction stream pattern as the existing TestPreparedStatement* tests:

  • TestPrepareSubstrait: the CreatePreparedSubstraitPlan action carries the plan bytes and Substrait version; the returned handle, dataset schema and parameter schema are parsed; IsUpdate reports no hint when is_update is absent; the statement executes through the shared CommandPreparedStatementQuery path and closes cleanly.
  • TestPrepareSubstraitWithIsUpdateFalse and TestPrepareSubstraitWithIsUpdateTrue: the is_update hint survives the round trip for both values, mirroring the server-side TestExecutePreparedSubstrait* cases.
  • TestTxnPrepareSubstrait: Txn.PrepareSubstrait sends the transaction ID from BeginTransaction together with the plan.

A small helper, mockCreatePreparedSubstraitPlan, registers the create and close expectations so the four cases stay short. Query and update execution are not duplicated here, as noted in the issue, since Substrait and SQL prepared statements share the same execution paths after creation.

Are these changes tested?

Yes, this PR only adds tests.

  • go test ./arrow/flight/flightsql/... -run TestFlightSqlClient: ok (29 subtests, 4 new)
  • go vet ./arrow/flight/flightsql/ and gofmt -l arrow/flight/flightsql: clean

Are there any user-facing changes?

No.

Closes #1267

AI/LLM disclosure

  • AI coding tools (Claude Code) were used to write these tests and this description.
  • The tests were reviewed and the commands above were run locally before submitting.

… statements

Cover Client.PrepareSubstrait and Txn.PrepareSubstrait in FlightSqlClientSuite:
the CreatePreparedSubstraitPlan action carries the plan bytes, version and
transaction ID, the returned handle and schemas are parsed, and the is_update
hint survives the round trip for the absent, false and true cases.

Closes apache#1267

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

Thanks, this fills the client-side gap left by #732. I checked that the tests catch real regressions: removing Version from either request, or TransactionId from the transaction request, makes them fail. Two optional nits:

  • The IsUpdate* and Txn tests use defer prepared.Close(...), which discards the error. s.NoError(prepared.Close(...)), as in TestPrepareSubstrait, would also catch a broken close.
  • TestTxnPrepareSubstrait uses defer to check its begin-transaction mock, while the helper uses t.Cleanup. Either works, but one style would be easier to read.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.

@zeroshade
zeroshade merged commit f38d8f3 into apache:main Oct 19, 2026
23 checks passed
@sankalpsthakur
sankalpsthakur deleted the GH-1267-flightsql-substrait-client-tests branch October 19, 2026 21:03
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.

[Flight SQL] Add client-side tests for Substrait prepared statements

2 participants