Skip to content

Commit

Permalink
fixup! Add GeneratedClassRowTypeConstraint, plumb options
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNeuralBit committed Aug 9, 2022
1 parent 03a2fea commit 49e915a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sdks/python/apache_beam/typehints/row_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,16 @@ def get_type_for(self, name):


class GeneratedClassRowTypeConstraint(RowTypeConstraint):
"""Specialization of RowTypeConstraint which relies on a generated user_type.
Since the generated user_type cannot be pickled, we supply a custom __reduce__
function that will regenerate the user_type.
"""
def __init__(
self,
fields,
schema_options: Optional[Sequence[Tuple[str, Any]]] = None,
field_options: Optional[Dict[str, Sequence[Tuple[str, Any]]]] = None):
# TODO: Move NamedTuple generation here?
from apache_beam.typehints.schemas import named_tuple_from_schema
from apache_beam.typehints.schemas import named_fields_to_schema
user_type = named_tuple_from_schema(
Expand Down

0 comments on commit 49e915a

Please sign in to comment.