Repository navigation
Fix Storage Read Avro schema names and NULL values - #531
Closed
alejandrohdezma wants to merge 2 commits into
Closed
alejandrohdezma wants to merge 2 commits into
alejandrohdezma wants to merge 2 commits into
Conversation
The Avro schema of a read session used the table's project and dataset IDs as its namespace and the table ID as its name. Those IDs can hold characters that Avro names do not allow, such as hyphens or a leading digit, so the emulator failed to build its own codec and reading the table failed. A query's anonymous result table has a random ID that can start with a digit, so reading query results failed too. BigQuery names the record __root__ and gives it no namespace, so the emulator does the same. The namespace is left out of the JSON schema when empty, as in BigQuery's read session schemas. TestStorageReadAVROMatchesBigQuery reads a table in a project and dataset whose IDs have hyphens, and a query's result table, and checks the schema name and the decoded rows.
A NULL in a nullable field was encoded as a map keyed by the field's
type, such as {"string": nil}. goavro reads that map as the non-null
branch of the field's union, so encoding failed with "value does not
match its schema" and the read stream returned an error. goavro encodes
nil as the null branch.
TestStorageReadAVROMatchesBigQuery now has a NULL in its nullable
column.
Fixes #252
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.
💻 How to review this PR?
This PR was created with the idea of being reviewed commit by commit. Each commit contains an incremental change that makes it easier to review. Also some of the commits contain additional information in their description to help understand why the change was made.
I also recommend checking "Hide whitespace" when reviewing this PR!
🚀 What's included in this PR?
__root__with no namespace, as BigQuery does. The schema used the table's project and dataset IDs as its namespace and the table ID as its name. Those can hold characters that Avro names do not allow (hyphens, a leading digit), so reading the table failed, and so did reading a query's anonymous result table, whose random ID can start with a digit.nil, the null branch of its union, instead of{"<type>": nil}.Fixes #252
TestStorageReadAVROMatchesBigQueryreads a table in projecttest-projectand datasetmy-datasetwith a NULL in a nullable column, and a query's result table, and checks the schema name and the decoded rows. The fixes were also checked with the Java client (google-cloud-bigquerystorage), through a Scala test suite that reads query results with the Storage Read API: it fails on v0.8.1 and passes with this branch.Notes
go test ./test/e2e/...fails for the Ruby client on this branch and onmain(cb8555b) withArgumentError: wrong number of arguments (given 2, expected 1)in every case.gems.txtpins onlygoogle-cloud-bigquery, so its dependencies resolve to newer versions on each build.docker buildfails onmain:golang:bookwormis now Go 1.27, and grpc v1.81.1 useshttp2.TrailerPrefix, whichx/netv0.54.0 leaves out under Go 1.27. I'll open a separate PR that pins the Go version.