Skip to content

Commit

Permalink
test mapping before iter
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwb committed Sep 15, 2023
1 parent ff7fc63 commit 1d962bf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sdks/python/apache_beam/typehints/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,16 @@ def typing_to_runner_api(self, type_: type) -> schema_pb2.FieldType:
return schema_pb2.FieldType(
array_type=schema_pb2.ArrayType(element_type=element_type))

elif _safe_issubclass(type_, Iterable) and not _safe_issubclass(type_, str):
element_type = self.typing_to_runner_api(_get_args(type_)[0])
return schema_pb2.FieldType(
array_type=schema_pb2.ArrayType(element_type=element_type))

elif _safe_issubclass(type_, Mapping):
key_type, value_type = map(self.typing_to_runner_api, _get_args(type_))
return schema_pb2.FieldType(
map_type=schema_pb2.MapType(key_type=key_type, value_type=value_type))

elif _safe_issubclass(type_, Iterable) and not _safe_issubclass(type_, str):
element_type = self.typing_to_runner_api(_get_args(type_)[0])
return schema_pb2.FieldType(
array_type=schema_pb2.ArrayType(element_type=element_type))

try:
logical_type = LogicalType.from_typing(type_)
except ValueError:
Expand Down

0 comments on commit 1d962bf

Please sign in to comment.