diff --git a/google/cloud/bigquery/schema.py b/google/cloud/bigquery/schema.py index c8b43d597..3003af250 100644 --- a/google/cloud/bigquery/schema.py +++ b/google/cloud/bigquery/schema.py @@ -259,11 +259,10 @@ def __init__( if self._properties.get("foreignTypeDefinition") is None: raise ValueError( "If the 'field_type' is 'FOREIGN', then 'foreign_type_definition' is required." - ) + ) if fields: # Don't set the property if it's not set. self._properties["fields"] = [field.to_api_repr() for field in fields] - @classmethod def from_api_repr(cls, api_repr: dict) -> "SchemaField": """Return a ``SchemaField`` object deserialized from a dictionary. diff --git a/tests/unit/test_schema.py b/tests/unit/test_schema.py index f87419df0..07cea2d9e 100644 --- a/tests/unit/test_schema.py +++ b/tests/unit/test_schema.py @@ -314,6 +314,11 @@ def test_fields_property(self): schema_field = self._make_one("boat", "RECORD", fields=fields) self.assertEqual(schema_field.fields, fields) + def test_roundingmode_property_str(self): + ROUNDINGMODE = "ROUNDING_MODE_UNSPECIFIED" + schema_field = self._make_one("test", "STRING", rounding_mode=ROUNDINGMODE) + self.assertEqual(schema_field.rounding_mode, ROUNDINGMODE) + def test_to_standard_sql_simple_type(self): examples = ( # a few legacy types