Skip to content

Commit dd04cad

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

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

sdks/python/apache_beam/typehints/native_type_compatibility.py

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

196+
print('check ', user_type)
197+
198+
# pylint: disable=wrong-import-position
199+
try:
200+
from apache_beam.options.pipeline_options_context import get_pipeline_options # pylint: disable=line-too-long
201+
except AttributeError:
202+
pass
203+
else:
204+
print('check 3 ', user_type)
205+
opts = get_pipeline_options()
206+
if opts and opts.is_compat_version_prior_to("2.73.0"):
207+
return False
208+
209+
print('check 2 ', user_type)
210+
196211
is_frozen = user_type.__dataclass_params__.frozen
197212
# avoid circular import
198213
try:
199-
# pylint: disable=wrong-import-position
200214
from apache_beam.coders.typecoders import registry as coders_registry
201215
from apache_beam.coders import RowCoder
202216
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)