Skip to content

Commit 5c4be39

Browse files
author
Regan Koopmans
committed
chore: address review comments
1 parent f6c4c27 commit 5c4be39

File tree

1 file changed

+9
-8
lines changed
  • packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1

1 file changed

+9
-8
lines changed

packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1/schema.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
types.TableFieldSchema.Type.JSON: descriptor_pb2.FieldDescriptorProto.TYPE_STRING,
5151
# INTERVAL is represented as a string
5252
types.TableFieldSchema.Type.INTERVAL: descriptor_pb2.FieldDescriptorProto.TYPE_STRING,
53-
# STRUCT and RANGE use TYPE_MESSAGE and are handled specially
54-
types.TableFieldSchema.Type.STRUCT: descriptor_pb2.FieldDescriptorProto.TYPE_MESSAGE,
55-
types.TableFieldSchema.Type.RANGE: descriptor_pb2.FieldDescriptorProto.TYPE_MESSAGE,
5653
}
5754

5855

@@ -154,11 +151,11 @@ def _convert_bq_table_schema_to_proto_descriptor_impl(
154151
field_number = 1
155152

156153
for bq_field in table_schema.fields:
157-
# Sanitize the field name for use in scope
158-
scope_name = _sanitize_field_name(bq_field.name)
159-
current_scope = f"{scope}__{scope_name}"
160-
161154
if bq_field.type_ == types.TableFieldSchema.Type.STRUCT:
155+
# Sanitize the field name for use in scope
156+
scope_name = _sanitize_field_name(bq_field.name)
157+
current_scope = f"{scope}__{scope_name}"
158+
162159
# Recursively convert nested struct
163160
nested_schema = types.TableSchema(fields=list(bq_field.fields))
164161
nested_descriptor, deeply_nested = _convert_bq_table_schema_to_proto_descriptor_impl(
@@ -172,6 +169,10 @@ def _convert_bq_table_schema_to_proto_descriptor_impl(
172169
fields.append(field)
173170

174171
elif bq_field.type_ == types.TableFieldSchema.Type.RANGE:
172+
# Sanitize the field name for use in scope
173+
scope_name = _sanitize_field_name(bq_field.name)
174+
current_scope = f"{scope}__{scope_name}"
175+
175176
# Validate RANGE element type
176177
if not bq_field.range_element_type or not bq_field.range_element_type.type_:
177178
raise ValueError(
@@ -217,7 +218,7 @@ def _convert_bq_table_schema_to_proto_descriptor_impl(
217218

218219
else:
219220
# Primitive field
220-
field = _convert_bq_field_to_proto_field(bq_field, field_number, current_scope)
221+
field = _convert_bq_field_to_proto_field(bq_field, field_number, "")
221222
fields.append(field)
222223

223224
field_number += 1

0 commit comments

Comments
 (0)