Skip to content
Closed

Minstant #35400

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"comment": "Modify this file in a trivial way to cause this test suite to run",
"modification": 6
"modification": 1
}
3 changes: 2 additions & 1 deletion sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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.utils.timestamp import MillisTimestamp
from apache_beam.utils.timestamp import Timestamp

# pylint: disable=wrong-import-order, wrong-import-position, ungrouped-imports
Expand Down Expand Up @@ -76,7 +77,7 @@
("renamed_varchar", str),
("renamed_bytes", bytes),
("renamed_varbytes", bytes),
("renamed_timestamp", Timestamp),
("renamed_timestamp", MillisTimestamp),
("renamed_decimal", Decimal),
("renamed_date", datetime.date),
("renamed_time", datetime.time),
Expand Down
5 changes: 3 additions & 2 deletions sdks/python/apache_beam/typehints/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
from apache_beam.typehints.schema_registry import SchemaTypeRegistry
from apache_beam.utils import proto_utils
from apache_beam.utils.python_callable import PythonCallableWithSource
from apache_beam.utils.timestamp import MillisTimestamp
from apache_beam.utils.timestamp import Timestamp

PYTHON_ANY_URN = "beam:logical:pythonsdk_any:v1"
Expand Down Expand Up @@ -864,7 +865,7 @@ def _from_typing(cls, typ):


@LogicalType.register_logical_type
class MillisInstant(NoArgumentLogicalType[Timestamp, np.int64]):
class MillisInstant(NoArgumentLogicalType[MillisTimestamp, np.int64]):
"""Millisecond-precision instant logical type handles values consistent with
that encoded by ``InstantCoder`` in the Java SDK.

Expand All @@ -890,7 +891,7 @@ def urn(cls):

@classmethod
def language_type(cls):
return Timestamp
return MillisTimestamp

def to_language_type(self, value):
# type: (np.int64) -> Timestamp
Expand Down
7 changes: 7 additions & 0 deletions sdks/python/apache_beam/utils/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@ def __mod__(self, other: DurationTypes) -> 'Duration':
return Duration(micros=self.micros % other.micros)


class MillisTimestamp():
"""A stub type used during registration to allow multiple logical types to
use the same Timestamp language type but with different to_language_type.
"""
pass


# The minimum granularity / interval expressible in a Timestamp / Duration
# object.
TIME_GRANULARITY = Duration(micros=1)
Loading