Skip to content

Commit

Permalink
fix: support merging for NUMERIC values (#434)
Browse files Browse the repository at this point in the history
Fixes #433
  • Loading branch information
larkee committed Jul 29, 2021
1 parent 93c09ab commit 06b4215
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions google/cloud/spanner_v1/streamed.py
Expand Up @@ -315,6 +315,7 @@ def _merge_struct(lhs, rhs, type_):
TypeCode.STRING: _merge_string,
TypeCode.STRUCT: _merge_struct,
TypeCode.TIMESTAMP: _merge_string,
TypeCode.NUMERIC: _merge_string,
}


Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_streamed.py
Expand Up @@ -164,6 +164,19 @@ def test__merge_chunk_bool(self):
with self.assertRaises(Unmergeable):
streamed._merge_chunk(chunk)

def test__merge_chunk_numeric(self):
from google.cloud.spanner_v1 import TypeCode

iterator = _MockCancellableIterator()
streamed = self._make_one(iterator)
FIELDS = [self._make_scalar_field("total", TypeCode.NUMERIC)]
streamed._metadata = self._make_result_set_metadata(FIELDS)
streamed._pending_chunk = self._make_value(u"1234.")
chunk = self._make_value(u"5678")

merged = streamed._merge_chunk(chunk)
self.assertEqual(merged.string_value, u"1234.5678")

def test__merge_chunk_int64(self):
from google.cloud.spanner_v1 import TypeCode

Expand Down

0 comments on commit 06b4215

Please sign in to comment.