Skip to content

Commit 2b3a4f8

Browse files
committed
Add stub type to register multiple logical types mapping to same language type.
1 parent c786cd0 commit 2b3a4f8

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

sdks/python/apache_beam/typehints/schemas.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,15 @@ def _from_typing(cls, typ):
863863
('micros', np.int64)])
864864

865865

866+
class MillisTimestamp():
867+
"""A stub type used during registration to allow multiple logical types to
868+
use the same Timestamp language type but with different to_language_type.
869+
"""
870+
pass
871+
872+
866873
@LogicalType.register_logical_type
867-
class MillisInstant(NoArgumentLogicalType[Timestamp, np.int64]):
874+
class MillisInstant(NoArgumentLogicalType[MillisTimestamp, np.int64]):
868875
"""Millisecond-precision instant logical type handles values consistent with
869876
that encoded by ``InstantCoder`` in the Java SDK.
870877
@@ -890,7 +897,7 @@ def urn(cls):
890897

891898
@classmethod
892899
def language_type(cls):
893-
return Timestamp
900+
return MillisTimestamp
894901

895902
def to_language_type(self, value):
896903
# type: (np.int64) -> Timestamp

0 commit comments

Comments
 (0)