Skip to content

Commit

Permalink
yet another round of merge conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
chalmerlowe committed Jan 2, 2025
2 parents db6ef9e + 0b0b85a commit ba2795b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
4 changes: 1 addition & 3 deletions google/cloud/bigquery/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import collections
import copy
import enum
from typing import Any, cast, Dict, Iterable, Optional, Union
from typing import Any, cast, Dict, Iterable, Optional, Union, Mapping, List

from google.cloud.bigquery import _helpers
from google.cloud.bigquery import standard_sql
Expand Down Expand Up @@ -260,8 +260,6 @@ def __init__(
raise ValueError(
"If the 'field_type' is 'FOREIGN', then 'foreign_type_definition' is required."
)
self._properties["type"] = field_type

if fields: # Don't set the property if it's not set.
self._properties["fields"] = [field.to_api_repr() for field in fields]

Expand Down
28 changes: 24 additions & 4 deletions tests/unit/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.


import copy
import unittest
from unittest import mock

Expand Down Expand Up @@ -851,11 +852,30 @@ def test_schema_fields_sequence(self):

def test_unknown_properties(self):
schema = [
{"name": "full_name", "type": "STRING", "mode": "REQUIRED"},
{"name": "address", "invalid_key": "STRING", "mode": "REQUIRED"},
{
"name": "full_name",
"type": "STRING",
"mode": "REQUIRED",
"someNewProperty": "test-value",
},
{
"name": "age",
# Note: This type should be included, too. Avoid client-side
# validation, as it could prevent backwards-compatible
# evolution of the server-side behavior.
"typo": "INTEGER",
"mode": "REQUIRED",
"anotherNewProperty": "another-test",
},
]
with pytest.raises(Exception): # Or a more specific exception if known
_to_schema_fields(schema)

# Make sure the setter doesn't mutate schema.
expected_schema = copy.deepcopy(schema)

result = self._call_fut(schema)

for api_repr, field in zip(expected_schema, result):
assert field.to_api_repr() == api_repr

@pytest.mark.parametrize(
"schema, expected_schema",
Expand Down

0 comments on commit ba2795b

Please sign in to comment.