shunping commented on code in PR #35243:
URL: https://github.com/apache/beam/pull/35243#discussion_r2161737747
##########
sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py:
##########
@@ -255,10 +253,6 @@ def test_xlang_jdbc_write_read(self, database):
classpath=config['classpath'],
))
- # Register MillisInstant logical type to override the mapping from
Timestamp
- # originally handled by MicrosInstant.
- LogicalType.register_logical_type(MillisInstant)
Review Comment:
So the two logical types `MillisInstant`
(https://github.com/apache/beam/blob/5532af8438fca1bcffc221a2b9394dc31c342425/sdks/python/apache_beam/typehints/schemas.py#L867)
and `MicrosInstant`
(https://github.com/apache/beam/blob/5532af8438fca1bcffc221a2b9394dc31c342425/sdks/python/apache_beam/typehints/schemas.py#L911)
both register `Timestamp` as their language type and `MillisInstant` goes
first and then `MicrosIntant` goes second in the file.
There is a map internally to map a language type to its logical type and it
is used when it tries to determine the coder. Without my fix and the
workaround, the internal map is going to map `Timestamp` to `MicroInstant`.
Then the whole code path when determining the coder of `MillisInstant` will
be `MillisInstant` -> `TimeStamp` -> Logical Type of `TimeStamp` ->
`MicroInstant` and its representation type.
The workaround is to calling the register function again for
`MillisInstant`, so that it overwrite the internal mapping to `Timestamp` ->
`Millistant`.
My fix was trying to eliminate the need of the workaround.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]