Details
-
Bug
-
Status: Open
-
P3
-
Resolution: Unresolved
-
None
-
None
Description
When inferring PCollection element types, merge Unions of identically-sized Tuples:
Union[Tuple[a, b], Tuple[c, d]] => Tuple[Union[a, c], Union[b, d]]
cc: robertwb
Example:
def fn(element: Tuple[str, Any]): .... p | Create([('a', None), ('b', None)] + [('c', 1), ('d', 3)]) | ParDo(fn)
This pipeline will fail with something like:
apache_beam.typehints.decorators.TypeCheckError: Type hint violation for 'ParDo': requires Tuple[str, Any] but got Union[Tuple[str, NoneType], Tuple[str, int]] for element
In test form:
def test_union_of_tuple(self):
self.assertCompatible(
typehints.Tuple[str, typehints.Any],
typehints.Union[typehints.Tuple[str, type(None)],
typehints.Tuple[str, int]])