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

fix: support merging for NUMERIC values #434

Merged
merged 1 commit into from Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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