You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Udi Meiri (Jira)" <ji...@apache.org> on 2019/10/23 16:58:00 UTC

[jira] [Created] (BEAM-8464) Python typehints: merge unions of tuples of the same size

Udi Meiri created BEAM-8464:
-------------------------------

             Summary: Python typehints: merge unions of tuples of the same size
                 Key: BEAM-8464
                 URL: https://issues.apache.org/jira/browse/BEAM-8464
             Project: Beam
          Issue Type: Bug
          Components: sdk-py-core
            Reporter: Udi Meiri


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:
{code}
def fn(element: Tuple[str, Any]):
  ....
p | Create([('a', None), ('b', None)] + [('c', 1), ('d', 3)]) | ParDo(fn)
{code}
This pipeline will fail with something like:
{code}
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
{code}

In test form:
{code}
  def test_union_of_tuple(self):
    self.assertCompatible(
        typehints.Tuple[str, typehints.Any],
        typehints.Union[typehints.Tuple[str, type(None)],
                        typehints.Tuple[str, int]])
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)