Skip to content

Commit

Permalink
Fix missing BYTES merger
Browse files Browse the repository at this point in the history
Client needs to know which merger to use when merging column type BYTES that is consumed in chunks as part of a read. Without this fix, client gives a traceback:
.../venv/lib/python2.7/site-packages/google/cloud/spanner/streamed.py", line 262, in _merge_by_type
    merger = _MERGE_BY_TYPE[type_.code]
KeyError: 7
Type 7 is BYTES from the proto definition (https://github.com/googleapis/googleapis/blob/master/google/spanner/v1/type.proto)
The error condition will arise if you write an image (a few MB in size) as base64 encoded in a bytes column. When trying to read the column back using the client, the above traceback will be given. With this fix, the client will use the string merger (treating bytes as a string) and allow the row to be consumed. The test is to read the entire column (with this fix) and write the bytes back to a file (base64 decoded).
  • Loading branch information
samizuh authored Apr 4, 2017
1 parent ff9ff61 commit 95481dc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions spanner/google/cloud/spanner/streamed.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def _merge_struct(lhs, rhs, type_):
type_pb2.STRING: _merge_string,
type_pb2.ARRAY: _merge_array,
type_pb2.STRUCT: _merge_struct,
type_pb2.BYTES: _merge_string,
}


Expand Down

0 comments on commit 95481dc

Please sign in to comment.