Skip to content

Commit

Permalink
materialize-bigquery: validate bignumeric columns as integer or number
Browse files Browse the repository at this point in the history
We used to create number columns as "bignumeric" (see
estuary#859.), and now create strings formatted as integer
columns as "bignumeric". Allowing "bignumeric" columns to be either integer or number compatible
allows both new and old materializations to work.
  • Loading branch information
williamhbaker committed Jan 24, 2024
1 parent ea3eeca commit 51504a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion materialize-bigquery/sqlgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var bqDialect = func() sql.Dialect {
sql.ColValidation{Types: []string{"int64"}, Validate: sql.IntegerCompatible},
sql.ColValidation{Types: []string{"float64"}, Validate: sql.NumberCompatible},
sql.ColValidation{Types: []string{"json"}, Validate: sql.MultipleCompatible},
sql.ColValidation{Types: []string{"bignumeric"}, Validate: sql.IntegerCompatible},
sql.ColValidation{Types: []string{"bignumeric"}, Validate: bignumericCompatible},
sql.ColValidation{Types: []string{"date"}, Validate: sql.DateCompatible},
sql.ColValidation{Types: []string{"timestamp"}, Validate: sql.DateTimeCompatible},
)
Expand Down Expand Up @@ -118,6 +118,13 @@ var bqDialect = func() sql.Dialect {
}
}()

// bignumericCompatible allows either integers or numbers, since we used to create number columns as
// "bignumeric" (now they are float64), and currently create strings formatted as integers as
// "bignumeric". This is needed for compatibility for older materializations.
func bignumericCompatible(p pf.Projection) bool {
return sql.IntegerCompatible(p) || sql.NumberCompatible(p)
}

// stringCompatible allow strings of any format, arrays, or objects to be materialized.
func stringCompatible(p pf.Projection) bool {
if sql.StringCompatible(p) {
Expand Down

0 comments on commit 51504a8

Please sign in to comment.