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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to insert or update JSON #1759

Closed
pacepace opened this issue Dec 27, 2023 · 3 comments
Closed

Unable to insert or update JSON #1759

pacepace opened this issue Dec 27, 2023 · 3 comments
Labels
api: bigquery Issues related to the googleapis/python-bigquery API.

Comments

@pacepace
Copy link

pacepace commented Dec 27, 2023

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'

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Dec 27, 2023
@pacepace pacepace changed the title Unable to insert or merge JSON Unable to insert or update JSON Dec 27, 2023
@HenryLee19
Copy link

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
Copy link

calbach commented Jan 8, 2024

I'm seeing the same error. This was functional for me on version 3.13.0.

@bricker
Copy link

bricker commented Jan 10, 2024

This is fixed in 3.15.0.

Relevant links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API.
Projects
None yet
Development

No branches or pull requests

4 participants