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
move test case closer to related test
  • Loading branch information
suzmue committed Aug 3, 2024
commit 83ee4aa7d8e851db70295eb33131cfc867a88b18
16 changes: 8 additions & 8 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,6 @@ def test_w_unknown_type(self):
self.assertEqual(self._call_fut(row, schema=[col]), ('1',))
self.assertEqual(len(record), 1)

def test_w_unknown_type_repeated(self):
# SELECT 1 AS col
col = _Field("REPEATED", "col", "UNKNOWN")
row = {"f": [{"v": [{"v": "1"}, {"v": "2"}, {"v": "3"}]}]}
with pytest.warns(FutureWarning, match="Unknown field type 'UNKNOWN'.") as record:
self.assertEqual(self._call_fut(row, schema=[col]), (['1', '2', '3'],))
self.assertEqual(len(record), 1)

def test_w_single_scalar_geography_column(self):
# SELECT 1 AS col
col = _Field("REQUIRED", "geo", "GEOGRAPHY")
Expand All @@ -676,6 +668,14 @@ def test_w_single_array_column(self):
row = {"f": [{"v": [{"v": "1"}, {"v": "2"}, {"v": "3"}]}]}
self.assertEqual(self._call_fut(row, schema=[col]), ([1, 2, 3],))

def test_w_unknown_type_repeated(self):
# SELECT 1 AS col
col = _Field("REPEATED", "col", "UNKNOWN")
row = {"f": [{"v": [{"v": "1"}, {"v": "2"}, {"v": "3"}]}]}
with pytest.warns(FutureWarning, match="Unknown field type 'UNKNOWN'.") as record:
self.assertEqual(self._call_fut(row, schema=[col]), (['1', '2', '3'],))
self.assertEqual(len(record), 1)

def test_w_struct_w_nested_array_column(self):
# SELECT ([1, 2], 3, [4, 5]) as col
first = _Field("REPEATED", "first", "INTEGER")
Expand Down