Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support RANGE query parameters #1827

Merged
merged 14 commits into from
Mar 4, 2024
Prev Previous commit
Next Next commit
unit test coverage
  • Loading branch information
Linchin committed Feb 24, 2024
commit 094e47ca23bd3d74d390d666f9fc64e127ed07d5
6 changes: 3 additions & 3 deletions google/cloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,9 @@ def _serialize_range_element_value(self, value, type_):
return converter(value) # type: ignore
else:
raise ValueError(
f"Cannot covert range element value {type(value)}:{value}, "
"must be a datetime.datetime or datetime.date object, or "
"a string."
f"Cannot covert range element value from type {type_}, "
Linchin marked this conversation as resolved.
Show resolved Hide resolved
"must be one of the strings 'TIMESTAMP', 'DATE' "
"'DATETIME' or a RangeQueryParameterType object."
)

def __init__(
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,10 @@ def test_to_api_repr_wo_values(self):
self.assertEqual(param.to_api_repr(), EXPECTED)

def test_to_api_repr_unsupported_value_type(self):
with self.assertRaises(ValueError):
self._make_one(range_element_type="LONGSTRING")
with self.assertRaisesRegex(ValueError, "Cannot covert range element value from type"):
range_param = self._make_one(range_element_type="DATE", start = datetime.date.today())
range_param.range_element_type.type_._type = "LONG"
range_param.to_api_repr()

def test___eq__(self):
param = self._make_one(range_element_type="DATE", start="2016-08-11", name="foo")
Expand Down