-
Notifications
You must be signed in to change notification settings - Fork 7
Add geography tz conversion #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #53 +/- ##
==========================================
+ Coverage 91.43% 91.59% +0.16%
==========================================
Files 44 47 +3
Lines 3466 4032 +566
==========================================
+ Hits 3169 3693 +524
- Misses 297 339 +42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ea5fbbd to
ceb6692
Compare
There was a problem hiding this 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 adds time zone conversion functionality to chronify, enabling conversion of time series data from one time zone to another. The implementation includes support for single time zone conversions and per-column time zone conversions.
Key changes:
- Introduces
TimeZoneConverterandTimeZoneConverterByColumnclasses for time zone conversion operations - Adds
DatetimeRangeWithTZColumnconfiguration to support external time zone columns - Renames
IndexTimeRangeLocalTimetoIndexTimeRangeWithTZColumnandINDEX_LOCALtoINDEX_TZ_COLfor consistency - Refactors time range generator classes to separate public and private timestamp iteration methods
Reviewed Changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/chronify/time_zone_converter.py | New module implementing time zone conversion with two converter classes |
| src/chronify/time_configs.py | Adds DatetimeRangeWithTZColumn config and refactors time config hierarchy |
| src/chronify/datetime_range_generator.py | Refactors to support external time zone columns with new generator class |
| src/chronify/time_utils.py | Adds helper functions for time zone checking and name extraction |
| src/chronify/time_series_checker.py | Enhances timestamp validation to support external time zone columns |
| src/chronify/store.py | Adds convert_time_zone and convert_time_zone_by_column public API methods |
| tests/test_time_zone_converter.py | New comprehensive test suite for time zone conversion functionality |
| Multiple test files | Updates test functions to include return type annotations and use tzinfo type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/chronify/time_configs.py
Outdated
| raise InvalidValue(msg) | ||
| return time_zones | ||
|
|
||
| # Lixi TODO: ensure table schema has time_zone col? |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO comment should either be addressed or converted into a proper issue tracker item with more context about what needs to be done.
| # Lixi TODO: ensure table schema has time_zone col? | |
| # TODO(issue #123): Ensure table schema has the column specified by time_zone_column. |
src/chronify/time_configs.py
Outdated
| return self.time_zone_column | ||
|
|
||
| def get_time_zones(self) -> list[tzinfo | None]: | ||
| return [] # LIXI TODO |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO comment should either be addressed or include more context about what needs to be implemented for get_time_zones() in RepresentativePeriodTimeTZ.
| return [] # LIXI TODO | |
| # TODO: Implement logic to return the list of time zones represented by this dimension. | |
| # This may require accessing the unique values from the `time_zone_column` in the underlying data, | |
| # or otherwise determining which time zones are present. If this cannot be implemented here, | |
| # document why and how it should be handled by the caller or in a subclass. | |
| return [] |
|
@daniel-thom I've opened a new pull request, #58, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2998606 to
dda0b78
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 32 out of 32 changed files in this pull request and generated 12 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@lixiliu Reminder to squash and merge when ready. |
* initial commit * clean up * Add time_wrap feature for tz col conversion * Rename IndexTimeRangeLocalTime to IndexTimeRangeWithTZColumn * Rename INDEX_LOCAL to INDEX_TZ_COL * Rework time_zone_converter to output tz naive col * Common API * Revise DatetimeRangeWithTZColumn class and downstream funcs * keep time_zone in output for convert by col * some cleanup * mostly changing from ZoneInfo to tzinfo as typehint * fix mypy errors * more mypy stuff * Add pytest for time_utils * refactor time util funcs * Fix pytest issue * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix mypy! mypy mypy attempt 3 fix mypy error again * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply code review suggestions 2 * review suggestions * address comments v3 * potential parquet fix for spark hive * update sql functions * Show error * temp * final --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Addresses dsgrid Issues:
[1] Added TimeZoneConverter classes
TimeZoneConverterconverts a tz-aware time column to the new time zone by outputting the new time as a tz-naive time column and recording the time_zone info as a new column*TimeZoneConverterByColumnis used to convert from a single time zone to one or more time zones defined by a column in the input data table.wrap_time_allowed(but not interval_adjustment or time_based_data_adjustment). If true, the converted timestamps aligns with the original timestamps in clock time.[2] User can invoke two generic functions:
convert_time_zone()andconvert_time_zone_by_column()without having to call the class functions. Note:Future work: