diff --git a/sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py b/sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py index 54a473d1b52b..8045881c1a49 100644 --- a/sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py +++ b/sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py @@ -36,8 +36,6 @@ from apache_beam.testing.test_pipeline import TestPipeline from apache_beam.testing.util import assert_that from apache_beam.testing.util import equal_to -from apache_beam.typehints.schemas import LogicalType -from apache_beam.typehints.schemas import MillisInstant from apache_beam.utils.timestamp import Timestamp # pylint: disable=wrong-import-order, wrong-import-position, ungrouped-imports @@ -189,10 +187,6 @@ def test_xlang_jdbc_write_read(self, database): classpath=classpath, )) - # Register MillisInstant logical type to override the mapping from Timestamp - # originally handled by MicrosInstant. - LogicalType.register_logical_type(MillisInstant) - with TestPipeline() as p: p.not_use_test_runner_api = True result = ( diff --git a/sdks/python/apache_beam/io/jdbc.py b/sdks/python/apache_beam/io/jdbc.py index 903b0d1b0fef..d0b6e82a4963 100644 --- a/sdks/python/apache_beam/io/jdbc.py +++ b/sdks/python/apache_beam/io/jdbc.py @@ -360,6 +360,9 @@ def __init__( expansion_service or default_io_expansion_service(classpath), ) +# TODO(https://github.com/apache/beam/issues/28359) The following logical type +# definitions and registrations are workaround for #28359. Remove them when +# switched to portable Data and Time type for JdbcIO. @LogicalType.register_logical_type class JdbcDateType(LogicalType[datetime.date, MillisInstant, str]): @@ -455,3 +458,7 @@ def argument(self): @classmethod def _from_typing(cls, typ): return cls() + +# Register MillisInstant logical type to override the mapping from Timestamp +# originally handled by MicrosInstant. +LogicalType.register_logical_type(MillisInstant)