You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
Instead of setting the modeString as "" here, it should be set to Field.Mode.NULLABLE.name().
This causes the following problem: When the Field is deserialized from protobuf response from BigQuery, it might have mode set to null. Specifically this seems to happen when a table has been created with SQL CREATE TABLE as it doesn't support setting the field as NULLABLE explicitly.
Steps to reproduce
Create a BigQuery table with some nullable columns using CREATE TABLE.
Get the schema from Java with bigQuery.getTable().getSchema(), compare with a Schema you have created by setting the mode to Field.Mode.NULLABLE explicitly using Field.equals(field2).
Expected result: Both Schemas are equal.
Result: Schemas are inequal. This is because comparison is done for Protobuf representation where an empty String is a placeholder for null.
The Field mode normalization for null values is incorrect and sets it as an empty String.
java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Field.java
Lines 199 to 203 in 5703b70
Instead of setting the
modeStringas""here, it should be set toField.Mode.NULLABLE.name().This causes the following problem: When the Field is deserialized from protobuf response from BigQuery, it might have
modeset tonull. Specifically this seems to happen when a table has been created with SQLCREATE TABLEas it doesn't support setting the field asNULLABLEexplicitly.Steps to reproduce
Create a BigQuery table with some nullable columns using
CREATE TABLE.Get the schema from Java with
bigQuery.getTable().getSchema(), compare with aSchemayou have created by setting themodetoField.Mode.NULLABLEexplicitly usingField.equals(field2).Expected result: Both Schemas are equal.
Result: Schemas are inequal. This is because comparison is done for Protobuf representation where an empty String is a placeholder for null.
Code example