Skip to content

Commit 13236e6

Browse files
committed
Address review comments
1 parent e1fac0c commit 13236e6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

google/cloud/bigtable/data/_async/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,10 @@ async def execute_query(
758758
# Nested field in a MAP column named 'my_map'
759759
"my_map.key": my_pb2.MapKeyEnum, # If map keys were enums
760760
"my_map.value": my_pb2.MapValueMessage,
761+
762+
# PROTO field inside a STRUCT, where the STRUCT is the value in a MAP column
763+
"struct_map.value.nested_proto_field": my_pb2.DeeplyNestedProto,
764+
"struct_map.value.nested_enum_field": my_pb2.DeeplyNestedEnum
761765
}
762766
763767
Returns:

google/cloud/bigtable/data/_sync_autogen/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ def execute_query(
585585
# Nested field in a MAP column named 'my_map'
586586
"my_map.key": my_pb2.MapKeyEnum, # If map keys were enums
587587
"my_map.value": my_pb2.MapValueMessage,
588+
589+
# PROTO field inside a STRUCT, where the STRUCT is the value in a MAP column
590+
"struct_map.value.nested_proto_field": my_pb2.DeeplyNestedProto,
591+
"struct_map.value.nested_enum_field": my_pb2.DeeplyNestedEnum
588592
}
589593
590594
Returns:

tests/unit/data/execute_query/test_query_result_parsing_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ def test__array_of_structs_with_proto_and_enum(self):
523523
"field_name": "enum_field",
524524
"type_": enum_type(),
525525
},
526+
{
527+
"field_name": None,
528+
"type_": proto_type(),
529+
},
526530
]
527531
}
528532
}
@@ -538,6 +542,7 @@ def test__array_of_structs_with_proto_and_enum(self):
538542
"values": [
539543
{"bytes_value": singer1.SerializeToString()},
540544
{"int_value": 0}, # POP
545+
{"bytes_value": singer1.SerializeToString()},
541546
]
542547
}
543548
},
@@ -546,6 +551,7 @@ def test__array_of_structs_with_proto_and_enum(self):
546551
"values": [
547552
{"bytes_value": singer2.SerializeToString()},
548553
{"int_value": 1}, # JAZZ
554+
{"bytes_value": singer2.SerializeToString()},
549555
]
550556
}
551557
},
@@ -559,6 +565,7 @@ def test__array_of_structs_with_proto_and_enum(self):
559565
assert type(metadata_type.element_type) is SqlType.Struct
560566
assert type(metadata_type.element_type["proto_field"]) is SqlType.Proto
561567
assert type(metadata_type.element_type["enum_field"]) is SqlType.Enum
568+
assert type(metadata_type.element_type[2]) is SqlType.Proto
562569

563570
# without proto definition
564571
result = _parse_pb_value_to_python_value(
@@ -569,9 +576,11 @@ def test__array_of_structs_with_proto_and_enum(self):
569576
assert isinstance(result[0], Struct)
570577
assert result[0]["proto_field"] == singer1.SerializeToString()
571578
assert result[0]["enum_field"] == 0
579+
assert result[0][2] == singer1.SerializeToString()
572580
assert isinstance(result[1], Struct)
573581
assert result[1]["proto_field"] == singer2.SerializeToString()
574582
assert result[1]["enum_field"] == 1
583+
assert result[1][2] == singer2.SerializeToString()
575584

576585
# with proto definition
577586
result = _parse_pb_value_to_python_value(
@@ -581,16 +590,19 @@ def test__array_of_structs_with_proto_and_enum(self):
581590
{
582591
"array_field.proto_field": singer_pb2.Singer(),
583592
"array_field.enum_field": singer_pb2.Genre,
593+
"array_field": singer_pb2.Singer(),
584594
},
585595
)
586596
assert isinstance(result, list)
587597
assert len(result) == 2
588598
assert isinstance(result[0], Struct)
589599
assert result[0]["proto_field"] == singer1
590600
assert result[0]["enum_field"] == "POP"
601+
assert result[0][2] == singer1
591602
assert isinstance(result[1], Struct)
592603
assert result[1]["proto_field"] == singer2
593604
assert result[1]["enum_field"] == "JAZZ"
605+
assert result[1][2] == singer2
594606

595607
def test__map(self):
596608
_type = PBType(

0 commit comments

Comments
 (0)