Repository navigation
Map legacy FLOAT columns to FLOAT64 - #524
Open
kfirco-torq wants to merge 1 commit into
Open
kfirco-torq wants to merge 1 commit into
kfirco-torq wants to merge 1 commit into
Conversation
BigQuery's legacy FLOAT type name (what the REST API and most client libraries send for a float column) is FLOAT64. Type.TypeKind mapped it to GoogleSQL's 32-bit FLOAT, so a table created with a FLOAT column got a 32-bit column, and assigning any FLOAT64 expression to it failed to analyze: Value of type DOUBLE cannot be assigned to score, which has type FLOAT Map FLOAT to DOUBLE, like FLOAT64. The reverse mapping is unchanged.
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.
Problem
FLOATis BigQuery's legacy name forFLOAT64. The REST API, the Go client'sbigquery.FloatFieldType, and most other client libraries send it for float columns.types.Type.TypeKindmappedFLOATto GoogleSQL's 32-bitFLOAT, so a table created with aFLOATcolumn got a 32-bit column, and anyFLOAT64value assigned to it failed:Literals still worked, because GoogleSQL coerces a literal to the column's type.
Fix
Map
FLOATtoDOUBLE, the same asFLOAT64. The reverse mapping and the reported schema type are unchanged.Tests
TestLegacyFloatColumnIsFloat64(server/legacy_float_test.go) creates a table through the Go client with a top-levelFLOATcolumn and aFLOATfield inside aRECORD. It assigns aFLOAT64parameter to both and reads0.3back exactly. The test fails onmainand passes with this change.go test ./...passes, except fortest/e2eTestClientConformance/ruby. That test fails the same way onmainon my machine (ArgumentError: wrong number of arguments, a local Ruby/gem version issue) and has nothing to do with this change.