Skip to content

Commit 2ee6bf4

Browse files
authored
feat(bigquery): support type alias names for numeric/bignumeric schemas. (#3760)
1 parent 94a6850 commit 2ee6bf4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

bigquery/schema.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,12 @@ var (
206206
}
207207
// The API will accept alias names for the types based on the Standard SQL type names.
208208
fieldAliases = map[FieldType]FieldType{
209-
"BOOL": BooleanFieldType,
210-
"FLOAT64": FloatFieldType,
211-
"INT64": IntegerFieldType,
212-
"STRUCT": RecordFieldType,
209+
"BOOL": BooleanFieldType,
210+
"FLOAT64": FloatFieldType,
211+
"INT64": IntegerFieldType,
212+
"STRUCT": RecordFieldType,
213+
"DECIMAL": NumericFieldType,
214+
"BIGDECIMAL": BigNumericFieldType,
213215
}
214216
)
215217

bigquery/schema_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,8 @@ func TestSchemaFromJSON(t *testing.T) {
10471047
{"name":"aliased_integer","type":"INT64","mode":"REQUIRED","description":"Aliased required integer"},
10481048
{"name":"aliased_boolean","type":"BOOL","mode":"NULLABLE","description":"Aliased nullable boolean"},
10491049
{"name":"aliased_float","type":"FLOAT64","mode":"REQUIRED","description":"Aliased required float"},
1050-
{"name":"aliased_record","type":"STRUCT","mode":"NULLABLE","description":"Aliased nullable record"}
1050+
{"name":"aliased_record","type":"STRUCT","mode":"NULLABLE","description":"Aliased nullable record"},
1051+
{"name":"aliased_bignumeric","type":"BIGDECIMAL","mode":"NULLABLE","description":"Aliased nullable bignumeric"}
10511052
]`),
10521053
expectedSchema: Schema{
10531054
fieldSchema("Flat nullable string", "flat_string", "STRING", false, false, nil),
@@ -1066,6 +1067,7 @@ func TestSchemaFromJSON(t *testing.T) {
10661067
fieldSchema("Aliased nullable boolean", "aliased_boolean", "BOOLEAN", false, false, nil),
10671068
fieldSchema("Aliased required float", "aliased_float", "FLOAT", false, true, nil),
10681069
fieldSchema("Aliased nullable record", "aliased_record", "RECORD", false, false, nil),
1070+
fieldSchema("Aliased nullable bignumeric", "aliased_bignumeric", "BIGNUMERIC", false, false, nil),
10691071
},
10701072
},
10711073
{

0 commit comments

Comments
 (0)