fix(bind): accept dictionary-encoded bind parameter columns (CONV-2) - #282
Merged
Conversation
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
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.
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 — failedInvalidArgumentswithunsupported Arrow type Dictionary(Int32, Utf8)even though the value type is supported (REVIEW.md CONV-2).What changed
cell_valuegets aDictionaryarm (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 andARRAY<...>alike, and an unsupported value type is rejected with the same error as its plain form (on null cells too, vianull_dictionary_value, keeping the fail-loudly-on-every-row convention theDecimal128scale check set).insert_mutationsharescell_value.spanner_column_typesees 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
scripts/run-foundry-validation.shpointed 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).scripts/with-emulator.sh cargo testgreen (288 + 52 + 17 + 6 + 1).cargo clippy --all-targets --all-features -- -D warningsandcargo fmt --all --checkclean.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