Skip to content

Commit 57214f5

Browse files
committed
Add upgrade compatibility check for potential coder change
1 parent 49fa4dc commit 57214f5

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

sdks/python/apache_beam/typehints/native_type_compatibility.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,19 @@ def match_dataclass_for_row(user_type):
193193
if not dataclasses.is_dataclass(user_type):
194194
return False
195195

196+
# pylint: disable=wrong-import-position
197+
try:
198+
from apache_beam.options.pipeline_options_context import get_pipeline_options # pylint: disable=line-too-long
199+
except AttributeError:
200+
pass
201+
else:
202+
opts = get_pipeline_options()
203+
if opts and opts.is_compat_version_prior_to("2.73.0"):
204+
return False
205+
196206
is_frozen = user_type.__dataclass_params__.frozen
197207
# avoid circular import
198208
try:
199-
# pylint: disable=wrong-import-position
200209
from apache_beam.coders.typecoders import registry as coders_registry
201210
from apache_beam.coders import RowCoder
202211
except AttributeError:

sdks/python/apache_beam/typehints/native_type_compatibility_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ class NonFrozenRegisteredDC:
533533
foo: int
534534

535535
# pylint: disable=wrong-import-position
536+
from apache_beam.coders import RowCoder
536537
from apache_beam.coders import typecoders
537538
from apache_beam.coders.coders import FastPrimitivesCoder
538-
from apache_beam.coders import RowCoder
539539

540540
typecoders.registry.register_coder(FrozenRegisteredDC, RowCoder)
541541
typecoders.registry.register_coder(

0 commit comments

Comments
 (0)