Skip to content

Conversation

@lixiliu
Copy link
Collaborator

@lixiliu lixiliu commented Jan 16, 2026

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces time zone localization functionality to handle conversion of timezone-naive (TIMESTAMP_NTZ) timestamps to timezone-aware (TIMESTAMP_TZ) timestamps. The changes include new localizer classes, refactoring of time configuration models, updates to test utilities, and bug fixes.

Changes:

  • Added TimeZoneLocalizer and TimeZoneLocalizerByColumn classes for localizing tz-naive timestamps to standard time zones
  • Refactored time configuration models to include dtype field and consolidated IndexTimeRange classes
  • Updated test utilities and fixed API inconsistencies (np.concatnp.concatenate)

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/chronify/time_zone_localizer.py New module implementing time zone localization classes and functions
src/chronify/time_configs.py Added dtype field to DatetimeRange classes and consolidated IndexTimeRange classes
src/chronify/time.py Replaced DatetimeFormat with TimeDataType enum
src/chronify/store.py Added localize_time_zone and localize_time_zone_by_column methods
src/chronify/time_zone_converter.py Updated error messages and added dtype field usage
src/chronify/datetime_range_generator.py Refactored timestamp generation to use pd.date_range and improved handling of time zones
src/chronify/sqlalchemy/functions.py Updated to use dtype field instead of start_time_is_tz_naive()
src/chronify/time_series_mapper_index_time.py Added dtype field assignment in mapping creation
src/chronify/time_series_checker.py Fixed typo in docstring
tests/test_time_zone_localizer.py Comprehensive test coverage for new localization functionality
tests/test_store.py Integration tests for localize_time_zone methods
tests/test_time_zone_converter.py Updated error message test and refactored test utilities
tests/test_mapper_*.py Refactored to use list_timestamps() instead of _iter_timestamps()
tests/test_mapper_column_representative_to_datetime.py Fixed np.concat → np.concatenate
src/chronify/init.py Updated exports to remove deprecated IndexTimeRange classes
docs/how_tos/map_time_config.md Fixed np.concat → np.concatenate in documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from_schema = get_datetime_schema(2018, None, TimeIntervalType.PERIOD_BEGINNING, "base_table")
df = generate_datetime_dataframe(from_schema)
error = (
Exception,
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error type should be MissingValue instead of generic Exception. The actual implementation in localize_time_zone_by_column raises MissingValue at line 120 of src/chronify/time_zone_localizer.py, but this test expects a generic Exception.

Copilot uses AI. Check for mistakes.
and time_zone_column is not None
):
msg = f"Input {time_zone_column=} will be ignored. time_zone_column is already defined in the time_config."
raise Warning(msg)
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising Warning is incorrect. In Python, Warning is not an exception type meant to be raised. This should either use warnings.warn() to emit a warning, or raise a proper exception like InvalidParameter if this is an error condition.

Copilot uses AI. Check for mistakes.
dtype = TimeDataType.TIMESTAMP_NTZ
case (False, None):
dtype = TimeDataType.TIMESTAMP_TZ
# validate dype if provided
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'dype' to 'dtype'.

Suggested change
# validate dype if provided
# validate dtype if provided

Copilot uses AI. Check for mistakes.
Comment on lines +179 to +180
# if timestamps[0].tzinfo:
# timestamps = [x.astimezone(tz_name).replace(tzinfo=None) for x in timestamps]
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment appears to contain commented-out code.

Suggested change
# if timestamps[0].tzinfo:
# timestamps = [x.astimezone(tz_name).replace(tzinfo=None) for x in timestamps]

Copilot uses AI. Check for mistakes.
Comment on lines +332 to +333
# if time_zone_column not in from_schema.time_array_id_columns:
# msg = f"{time_zone_column=} must be in source schema time_array_id_columns."
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment appears to contain commented-out code.

Suggested change
# if time_zone_column not in from_schema.time_array_id_columns:
# msg = f"{time_zone_column=} must be in source schema time_array_id_columns."
# Note: time_zone_column is expected to be in from_schema.time_array_id_columns.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants