This is an automated email from the ASF dual-hosted git repository.

bhulette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 6c1c19d  [BEAM-12803] Update deprecated use of _field_types (#15539)
6c1c19d is described below

commit 6c1c19d6c711babf5f5f042fa465be20948caff6
Author: Jonathan Hourany <[email protected]>
AuthorDate: Mon Sep 20 14:43:03 2021 -0700

    [BEAM-12803] Update deprecated use of _field_types (#15539)
---
 sdks/python/apache_beam/dataframe/schemas.py                   | 2 +-
 sdks/python/apache_beam/runners/interactive/sql/utils.py       | 4 ++--
 sdks/python/apache_beam/typehints/native_type_compatibility.py | 2 +-
 sdks/python/apache_beam/typehints/schemas.py                   | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sdks/python/apache_beam/dataframe/schemas.py 
b/sdks/python/apache_beam/dataframe/schemas.py
index bd889da..200521b 100644
--- a/sdks/python/apache_beam/dataframe/schemas.py
+++ b/sdks/python/apache_beam/dataframe/schemas.py
@@ -234,7 +234,7 @@ class _BaseDataframeUnbatchDoFn(beam.DoFn):
     all_series = self._get_series(df)
     iterators = [
         make_null_checking_generator(series) for series,
-        typehint in zip(all_series, self._namedtuple_ctor._field_types)
+        typehint in zip(all_series, self._namedtuple_ctor.__annotations__)
     ]
 
     # TODO: Avoid materializing the rows. Produce an object that references the
diff --git a/sdks/python/apache_beam/runners/interactive/sql/utils.py 
b/sdks/python/apache_beam/runners/interactive/sql/utils.py
index 0c80505..1840e60 100644
--- a/sdks/python/apache_beam/runners/interactive/sql/utils.py
+++ b/sdks/python/apache_beam/runners/interactive/sql/utils.py
@@ -36,7 +36,7 @@ def is_namedtuple(cls: type) -> bool:
   """Determines if a class is built from typing.NamedTuple."""
   return (
       isinstance(cls, type) and issubclass(cls, tuple) and
-      hasattr(cls, '_fields') and hasattr(cls, '_field_types'))
+      hasattr(cls, '_fields') and hasattr(cls, '__annotations__'))
 
 
 def register_coder_for_schema(schema: NamedTuple) -> None:
@@ -117,5 +117,5 @@ def pformat_namedtuple(schema: NamedTuple) -> str:
       schema.__name__,
       ', '.join([
           '{}: {}'.format(k, v.__name__) for k,
-          v in schema._field_types.items()
+          v in schema.__annotations__.items()
       ]))
diff --git a/sdks/python/apache_beam/typehints/native_type_compatibility.py 
b/sdks/python/apache_beam/typehints/native_type_compatibility.py
index 3d69cd6..5d5ae96 100644
--- a/sdks/python/apache_beam/typehints/native_type_compatibility.py
+++ b/sdks/python/apache_beam/typehints/native_type_compatibility.py
@@ -107,7 +107,7 @@ def _match_is_exactly_iterable(user_type):
 def match_is_named_tuple(user_type):
   return (
       _safe_issubclass(user_type, typing.Tuple) and
-      hasattr(user_type, '_field_types'))
+      hasattr(user_type, '__annotations__'))
 
 
 def _match_is_optional(user_type):
diff --git a/sdks/python/apache_beam/typehints/schemas.py 
b/sdks/python/apache_beam/typehints/schemas.py
index 3ef035e..d62ba54 100644
--- a/sdks/python/apache_beam/typehints/schemas.py
+++ b/sdks/python/apache_beam/typehints/schemas.py
@@ -157,7 +157,7 @@ def typing_to_runner_api(type_):
     if schema is None:
       fields = [
           schema_pb2.Field(
-              name=name, type=typing_to_runner_api(type_._field_types[name]))
+              name=name, 
type=typing_to_runner_api(type_.__annotations__[name]))
           for name in type_._fields
       ]
       type_id = str(uuid4())

Reply via email to