-
Notifications
You must be signed in to change notification settings - Fork 98
feat: add support of float32 type #1113
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
Changes from 4 commits
9039963
7bbb15a
67e2e2c
bff3ec2
fa2aab6
243742e
ccf471c
f65f7ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,5 +90,8 @@ def _check_cell_data(found_cell, expected_cell, recurse_into_lists=True): | |
for found_item, expected_item in zip(found_cell, expected_cell): | ||
_check_cell_data(found_item, expected_item) | ||
|
||
elif isinstance(found_cell, float): | ||
assert abs(found_cell - expected_cell) < 0.00001 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
else: | ||
assert found_cell == expected_cell |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -466,6 +466,27 @@ def test_w_float_str(self): | |
|
||
self.assertEqual(self._callFUT(value_pb, field_type), expected_value) | ||
|
||
def test_w_float32(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per FLOAT32 design, the request from client is sent as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to verify both insert and read with this kind of data when column type is FLOAT32. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. behaviour for |
||
from google.cloud.spanner_v1 import Type, TypeCode | ||
from google.protobuf.struct_pb2 import Value | ||
|
||
VALUE = 3.14159 | ||
field_type = Type(code=TypeCode.FLOAT32) | ||
value_pb = Value(number_value=VALUE) | ||
|
||
self.assertEqual(self._callFUT(value_pb, field_type), VALUE) | ||
|
||
def test_w_float32_str(self): | ||
from google.cloud.spanner_v1 import Type, TypeCode | ||
from google.protobuf.struct_pb2 import Value | ||
|
||
VALUE = "3.14159" | ||
field_type = Type(code=TypeCode.FLOAT32) | ||
value_pb = Value(string_value=VALUE) | ||
expected_value = 3.14159 | ||
|
||
self.assertEqual(self._callFUT(value_pb, field_type), expected_value) | ||
|
||
def test_w_date(self): | ||
import datetime | ||
from google.protobuf.struct_pb2 import Value | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have integration tests for every type in test_session_api.py. Can we have a test for
FLOAT32
?Reference:
test_execute_sql_w_float64_bindings
andtest_execute_sql_w_float_bindings_transfinite