The Field mode normalization for null values is incorrect and sets it as an empty String. #2730
Labels
api: bigquery
Issues related to the googleapis/java-bigquery API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
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
mode
String
as""
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
mode
set tonull
. Specifically this seems to happen when a table has been created with SQLCREATE TABLE
as it doesn't support setting the field asNULLABLE
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 aSchema
you have created by setting themode
toField.Mode.NULLABLE
explicitly 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
The text was updated successfully, but these errors were encountered: