Skip to content
Permalink
Browse files
fix: support merging for NUMERIC values (#434)
Fixes #433
  • Loading branch information
larkee committed Jul 29, 2021
1 parent 93c09ab commit 06b4215f76ae806eba1d0d07115c8c90b8c7482d
Showing with 14 additions and 0 deletions.
  1. +1 −0 google/cloud/spanner_v1/streamed.py
  2. +13 −0 tests/unit/test_streamed.py
@@ -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,
}


@@ -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

0 comments on commit 06b4215

Please sign in to comment.