chore(c/validation): make TestSqlPrepareUpdate{,Stream} readback order deterministic - #29
Open
fornwall wants to merge 3 commits into
Open
Conversation
…quirk Several statement tests hardcode SQL that is not portable across SQL dialects: CREATE TABLE statements with INT/INTEGER/TEXT columns and no primary key, INSERT statements without a column list, SELECT * readbacks after create-mode ingest (which break on drivers that add a synthetic key column), ORDER BY ... NULLS FIRST/LAST, and bare parameter SELECTs whose types some engines cannot infer. Route each of these through the DriverQuirks::RewriteSql hook (added in apache#4496) with a stable query id, so driver test harnesses can substitute an equivalent query in their own dialect. The TestSqlIngestType query id carries the ingested Arrow type (ArrowTypeString) as a suffix, so quirks can rewrite per type — e.g. a dialect that cannot ORDER BY a list-typed column. No behavior changes for drivers that do not override RewriteSql: the default implementation returns the given SQL unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hsYQVXuHhnuiBD7XTVo65
fornwall
force-pushed
the
validation-prepare-update-ordering
branch
from
July 14, 2026 11:21
5bcd9c1 to
15f41c9
Compare
Pure line-rewrapping of the RewriteSql call sites to the pinned clang-format (v18.1.7 via pre-commit); no functional change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hsYQVXuHhnuiBD7XTVo65
…r deterministic TestSqlPrepareUpdate and TestSqlPrepareUpdateStream read back bulk_ingest with a plain "SELECT * FROM bulk_ingest" and then assert the returned rows positionally via CompareArray — i.e. they assert insertion order. SQL gives no ordering guarantee without ORDER BY, so this relies on engine-specific behavior: SQLite and PostgreSQL happen to return insertion order, but engines that return rows in primary-key order (e.g. Spanner, whose create-mode ingest keys the table on a synthetic UUID column) fail the assertion nondeterministically. Fix it with the suite's existing convention — the deterministic ORDER BY <col> ASC NULLS FIRST readback that TestSqlIngestType and TestSqlBind already use — and sort the expected vectors accordingly. The RewriteSql routing and query ids are unchanged; only the default SQL string gains the ORDER BY clause. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hsYQVXuHhnuiBD7XTVo65
fornwall
force-pushed
the
validation-prepare-update-ordering
branch
from
July 14, 2026 11:43
15f41c9 to
f956e97
Compare
fornwall
force-pushed
the
validation-rewrite-sql-sites
branch
3 times, most recently
from
July 14, 2026 12:08
62d8b0c to
6590897
Compare
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect
StatementTest::TestSqlPrepareUpdateandStatementTest::TestSqlPrepareUpdateStreamread back thebulk_ingesttable with a plainSELECT * FROM bulk_ingest— noORDER BY— and then assert the returned rows positionally viaCompareArray({42, -42, NULL, 42, -42, NULL}and{1, 2, NULL, 3, NULL, 3}respectively), i.e. they assert insertion order.SQL gives no ordering guarantee without
ORDER BY, so a positional assertion on an unorderedSELECTrelies on engine-specific behavior. SQLite and PostgreSQL happen to return insertion order, which is why these pass upstream; engines that return rows in primary-key order fail the assertion (for Spanner, whose create-mode bulk ingest keys the table on a syntheticadbc_ingest_key STRING(36) DEFAULT (GENERATE_UUID())column, the readback order is effectively random per run). The suite itself already treats this as a solved problem elsewhere:TestSqlIngestTypereads back withORDER BY "col" ASC NULLS FIRSTandTestSqlBindwithORDER BY col1 ASC NULLS FIRST.Fix
Give both readbacks the suite's existing deterministic-readback convention —
ORDER BY <quirks()->QuoteIdentifier(col)> ASC NULLS FIRST— and sort the expected vectors accordingly:TestSqlPrepareUpdate(int64s):{NULL, NULL, -42, -42, 42, 42}TestSqlPrepareUpdateStream(ints):{NULL, NULL, 1, 2, 3, 3}The
RewriteSqlrouting and query ids from #28 are unchanged — only the default SQL string passed toRewriteSqlgains theORDER BYclause, so drivers whose dialect rejectsNULLS FIRST(GoogleSQL) can still substitute an equivalent ordering via the quirk.Verification
Verified end-to-end against the Spanner ADBC driver's validation harness (
scripts/run-adbc-validation.shin fornwall/spanner-adbc, pinned to this commit, with the two cases removed from its expected-failure list and itsRewriteSqlquirk substitutingORDER BY ... ASCfor theNULLS FIRSTform): bothSpannerStatementTest.SqlPrepareUpdateandSpannerStatementTest.SqlPrepareUpdateStreampass — 84 passed / 7 skipped of 91, expected-failure gate green.Stacks on #28 (
validation-rewrite-sql-sites), which this PR is based on so the diff shows only this fix. Like #28, this is an upstreaming candidate for apache/arrow-adbc.🤖 Generated with Claude Code
https://claude.ai/code/session_011hsYQVXuHhnuiBD7XTVo65