Skip to content

bigquery: column option rounding_mode is deleted upon any update to table schema i.e. table.Update() #10311

@vova-panoplyio

Description

@vova-panoplyio

Client

cloud.google.com/go/bigquery@v1.60.0

Environment

doesn't matter here

Go Environment

Go 1.22

Scenario/How to reproduce

  1. Create a table with at least one numeric column.
  2. Execute SQL set options(rounding_mode = "ROUND_HALF_EVEN") on numeric column
  3. Numeric column shows ROUND_HALF_EVEN in INFORMATION_SCHEMA.COLUMNS.rounding_mode field
  4. Use standard code example that adds another column (as per below link)
  5. Numeric column's value in INFORMATION_SCHEMA.COLUMNS.rounding_mode field is now empty

Code
Identical to standard example:
https://github.com/GoogleCloudPlatform/golang-samples/blob/bdc987b4624a0939603bb9f0a74eb2b815aa6577/bigquery/snippets/table/bigquery_add_empty_column.go#L26

Expected behavior

New fields are added.
Existing fields are obviously unchanged including their options like rounding_mode.

P.S. My guess is that the cause is due to the fact that while Google API's TableFieldSchema contains roundingMode field (https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#tablefieldschema), the Go client's FieldSchema object doesn't not, thus the value is lost already during toBQ() call during getting Table/Metadata
(

func (fs *FieldSchema) toBQ() *bq.TableFieldSchema {
).

Then when code executes table update/patch with previously retrieved Table/Metadata, the underlying Google API call will always have empty roundingMode json param for all fields.
The description column option, on the other side, works fine, because it is reflected in FieldSchema object

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions