Skip to content

fix: add warning when encountering unknown field types #1989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 13, 2024
Merged
Prev Previous commit
Next Next commit
add unit test to StructQueryParameter class
  • Loading branch information
suzmue committed Aug 7, 2024
commit be54ee56d363685122500a7781f12d172a74d178
12 changes: 0 additions & 12 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,18 +1637,6 @@ def test_decimal_as_float_api_repr():
}


def test_unknown_type_as_api_repr():
"""Make sure decimals get converted to float."""
import google.cloud.bigquery.query

param = google.cloud.bigquery.query.ScalarQueryParameter("x", "UNKNOWN_TYPE", 54)
assert param.to_api_repr() == {
"parameterType": {"type": "UNKNOWN_TYPE"},
"parameterValue": {"value": 54},
"name": "x",
}


class Test__get_bigquery_host(unittest.TestCase):
@staticmethod
def _call_fut():
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,25 @@ def test_to_api_repr_w_nested_struct(self):
param = self._make_one("foo", scalar_1, sub)
self.assertEqual(param.to_api_repr(), EXPECTED)

def test_to_api_repr_w_unknown_type(self):
EXPECTED = {
"name": "foo",
"parameterType": {
"type": "STRUCT",
"structTypes": [
{"name": "bar", "type": {"type": "INT64"}},
{"name": "baz", "type": {"type": "UNKNOWN_TYPE"}},
],
},
"parameterValue": {
"structValues": {"bar": {"value": "123"}, "baz": {"value": "abc"}}
},
}
sub_1 = _make_subparam("bar", "INT64", 123)
sub_2 = _make_subparam("baz", "UNKNOWN_TYPE", "abc")
param = self._make_one("foo", sub_1, sub_2)
self.assertEqual(param.to_api_repr(), EXPECTED)

def test___eq___wrong_type(self):
field = self._make_one("test", _make_subparam("bar", "STRING", "abc"))
other = object()
Expand Down