Skip to content

feat: Proto column feature tests and samples #921

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

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ee311a2
feat: add integration tests for Proto Columns
harshachinta Mar 23, 2023
c569521
feat: add unit tests for Proto Columns
harshachinta Mar 23, 2023
3aeb55f
feat: update tests to add column_info argument at end
harshachinta Mar 24, 2023
f7cd162
feat: remove deepcopy during deserialization of proto message
harshachinta Mar 27, 2023
49948d0
feat: tests refactoring
harshachinta Mar 27, 2023
b596142
feat: integration tests refactoring
harshachinta Mar 27, 2023
d76e2d5
feat: samples and sample tests refactoring
harshachinta Mar 27, 2023
aca3c5b
feat: lint tests folder
harshachinta Mar 28, 2023
2ceec99
feat:lint samples directory
harshachinta Mar 28, 2023
8591cdc
feat: stop running emulator with proto ddl commands
harshachinta Mar 28, 2023
a267a01
feat: close the file after reading
harshachinta Mar 28, 2023
92a8b1a
feat: update protobuf version lower bound to >3.20 to check proto mes…
harshachinta Mar 28, 2023
ad635e5
feat: update setup for snippets_tests.py file
harshachinta Mar 28, 2023
c2f478c
feat: add integration tests
harshachinta Mar 28, 2023
dba4e01
feat: remove duplicate integration tests
harshachinta Mar 28, 2023
bc11399
feat: add proto_descriptor parameter to required tests
harshachinta Mar 29, 2023
914641b
feat: add compatibility tests between Proto message, Bytes and Proto …
harshachinta Mar 29, 2023
8d53f01
feat: add index tests for proto columns
harshachinta Mar 29, 2023
af79ddc
feat: replace duplicates with sample data
harshachinta Mar 29, 2023
30fe6ce
feat: update protobuf lower bound version in setup.py file to add sup…
harshachinta Mar 29, 2023
1f48b21
feat: lint fixes
harshachinta Mar 29, 2023
70482ee
feat: lint fix
harshachinta Mar 29, 2023
22d1786
feat: tests refactoring
harshachinta Mar 31, 2023
984f5fd
feat: change comment from dml to dql for read
harshachinta Mar 31, 2023
3deab18
feat: tests refactoring for update db operation
harshachinta Mar 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions google/cloud/spanner_v1/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ def _parse_value_pb(value_pb, field_type, field_name, column_info=None):
elif type_code == TypeCode.PROTO:
bytes_value = base64.b64decode(value_pb.string_value)
if column_info is not None and column_info.get(field_name) is not None:
proto_message = column_info.get(field_name)
if isinstance(proto_message, Message):
proto_message = proto_message.__deepcopy__()
default_proto_message = column_info.get(field_name)
if isinstance(default_proto_message, Message):
proto_message = type(default_proto_message)()
proto_message.ParseFromString(bytes_value)
return proto_message
return bytes_value
Expand Down
25 changes: 15 additions & 10 deletions samples/samples/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def multi_region_instance_config(spanner_client):

@pytest.fixture(scope="module")
def proto_descriptor_file():
return open("../../samples/samples/testdata/descriptors.pb", 'rb').read()
import os

dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, "testdata/descriptors.pb")
return open(filename, "rb").read()


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -209,12 +213,13 @@ def database_ddl():

@pytest.fixture(scope="module")
def sample_database(
spanner_client,
sample_instance,
database_id,
database_ddl,
database_dialect,
proto_descriptor_file):
spanner_client,
sample_instance,
database_id,
database_ddl,
database_dialect,
proto_descriptor_file,
):
if database_dialect == DatabaseDialect.POSTGRESQL:
sample_database = sample_instance.database(
database_id,
Expand All @@ -240,9 +245,9 @@ def sample_database(
return

sample_database = sample_instance.database(
database_id,
ddl_statements=database_ddl,
proto_descriptors=proto_descriptor_file
database_id,
ddl_statements=database_ddl,
proto_descriptors=proto_descriptor_file,
)

if not sample_database.exists():
Expand Down
Loading