Unable to insert or update JSON
pacepace opened this issue · 3 comments
pacepace commented
Environment details
- OS type and version: Windows 11 WSL2 Ubuntu 22.04
- Python version: 3.10.12
- pip version: 23.3.1
google-cloud-bigquery
version: 3.14.1
Steps to reproduce
The problem is in this code in query.py:
def to_api_repr(self) -> dict:
"""Construct JSON API representation for the parameter.
Returns:
Dict: JSON mapping
"""
value = self.value
converter = _SCALAR_VALUE_TO_JSON_PARAM.get(self.type_)
if converter is not None:
value = converter(value) # type: ignore
resource: Dict[str, Any] = {
"parameterType": {"type": self.type_},
"parameterValue": {"value": value},
}
if self.name is not None:
resource["name"] = self.name
return resource
As you can see, it calls converter with one argument. When using JSON, it uses this converter in _helpers.py:
def _json_from_json(value, field):
"""Coerce 'value' to a pythonic JSON representation, if set or not nullable."""
if _not_null(value, field):
return json.loads(value)
That needs two arguments and it is being given only one resulting in a TypeError: converter() missing 1 required positional argument: 'field'
HenryLee19 commented
The same error just broke my code as well:
File "/.../.../.../.../lib/python3.9/site-packages/google/cloud/bigquery/query.py", line 472, in to_api_repr
value = converter(value) # type: ignore
TypeError: _json_from_json() missing 1 required positional argument: 'field'
calbach commented
I'm seeing the same error. This was functional for me on version 3.13.0.