Skip to content

fix(bind): accept dictionary-encoded bind parameter columns (CONV-2) - #282

Merged
fornwall merged 1 commit into
mainfrom
fix/bind-dictionary-encoded
Jul 14, 2026
Merged

fix(bind): accept dictionary-encoded bind parameter columns (CONV-2)#282
fornwall merged 1 commit into
mainfrom
fix/bind-dictionary-encoded

Conversation

@fornwall

Copy link
Copy Markdown
Owner

Fixes the gap covered by fornwall/validation#6 (TestStatement.test_parameter_dictionary_encoded): binding a dictionary-encoded column — what pandas categoricals produce over the C data interface — failed InvalidArguments with unsupported Arrow type Dictionary(Int32, Utf8) even though the value type is supported (REVIEW.md CONV-2).

What changed

  • cell_value gets a Dictionary arm (src/bind.rs): dictionary encoding is an index representation of the same logical values, not a different logical type (the Arrow columnar format's "Dictionary-encoded Layout"), so the column binds transparently as its value type. The key at each row selects the dictionary value, which re-enters the same cell mapping — every bindable value type is accepted encoded, scalars and ARRAY<...> alike, and an unsupported value type is rejected with the same error as its plain form (on null cells too, via null_dictionary_value, keeping the fail-loudly-on-every-row convention the Decimal128 scale check set).
  • Mutation-based bulk ingest decodes the same way for free — insert_mutation shares cell_value.
  • spanner_column_type sees through the encoding, so ingest create modes map a dictionary column to its value type's Spanner column type.
  • RunEndEncoded (the other encoding CONV-2 mentions) stays rejected — no known producer emits it over the C data interface today; noted in REVIEW.md.

Verification

  • The origin validation test, run against the emulator via scripts/run-foundry-validation.sh pointed at test(statement): cover dictionary-encoded bind parameter columns validation#6's head: fails with the exact CONV-2 error before this change, passes after (verified both directions).
  • Full scripts/with-emulator.sh cargo test green (288 + 52 + 17 + 6 + 1).
  • Full foundry suite at its pinned upstream ref: 184 passed, 65 skipped.
  • cargo clippy --all-targets --all-features -- -D warnings and cargo fmt --all --check clean.
  • New unit tests cover decoded scalar + widened-int binds, a List-valued dictionary, null cells, sliced batches (non-zero key offsets), unsupported value types (null cells included), ingest mutations, and the DDL mapping.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FjqdweBVqxdegAHVDh97oV

cell_value had no arm for Arrow's Dictionary type, so a dictionary-encoded
column - what pandas categoricals produce over the C data interface - failed
InvalidArguments ("unsupported Arrow type Dictionary(Int32, Utf8)") even
though its value type was supported. Dictionary encoding is an index
representation of the same logical values, not a different logical type
(the Arrow columnar format's "Dictionary-encoded Layout"), so the column now
binds transparently as its value type: the key at each row selects the
dictionary value, which re-enters the same cell mapping - every bindable
value type is accepted encoded, scalars and ARRAY<...> alike, and an
unsupported value type is rejected with the same error as its plain form
(on null cells too, keeping the fail-loudly-on-every-row convention).

Because insert_mutation shares cell_value, mutation-based bulk ingest
decodes the same way, and spanner_column_type sees through the encoding so
the ingest create modes map such a column to its value type's Spanner
column type.

Verified against the emulator via the foundry harness running
fornwall/validation#6's new test_parameter_dictionary_encoded: fails with
the exact CONV-2 error before this change, passes after. Full emulator
cargo test and the pinned upstream foundry suite stay green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FjqdweBVqxdegAHVDh97oV
@fornwall
fornwall merged commit d254c32 into main Jul 14, 2026
22 checks passed
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.

1 participant