-
Notifications
You must be signed in to change notification settings - Fork 101
Closed
Labels
api: spannerIssues related to the googleapis/python-spanner API.Issues related to the googleapis/python-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
Description
The Python Spanner client does not support deserialising a JSON column which contains an array as the top level element. Although the insertion works (when pre-serialising using json.loads), reading back the row fails, either by returning incorrect data, or by throwing an error.
What is the business impact you are facing:
Unability to deploy a new feature in production relying on array values as top-level elements in JSON columns.
Environment details
- Python version: python3.8
google-cloud-spannerversion:Python client google-cloud-spanner 3.13.0
Description of the workload (business logic, access pattern, use case):
Accessing JSON columns using the Python client fails
Steps to reproduce
- https://github.com/flovouin/spanner-python-json-column#running-the-example
- ValueError: dictionary update sequence element #0 has length 1; 2 is required
JsonObject([{"myFirstObject": 1}])
Code example
https://github.com/flovouin/spanner-python-json-column
Stack trace
File "venv/lib/python3.8/site-packages/google/cloud/spanner_v1/streamed.py", line 145, in __iter__
self._consume_next()
File "venv/lib/python3.8/site-packages/google/cloud/spanner_v1/streamed.py", line 137, in _consume_next
self._merge_values(values)
File "venv/lib/python3.8/site-packages/google/cloud/spanner_v1/streamed.py", line 105, in _merge_values
self._current_row.append(_parse_value_pb(value, field_types[index]))
File "venv/lib/python3.8/site-packages/google/cloud/spanner_v1/_helpers.py", line 244, in _parse_value_pb
return JsonObject.from_str(value_pb.string_value)
File "venv/lib/python3.8/site-packages/google/cloud/spanner_v1/data_types.py", line 45, in from_str
return cls(json.loads(str_repr))
File "venv/lib/python3.8/site-packages/google/cloud/spanner_v1/data_types.py", line 30, in __init__
super(JsonObject, self).__init__(*args, **kwargs)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
flovouin and qbarlas
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the googleapis/python-spanner API.Issues related to the googleapis/python-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.