Skip to content

tz_issue_fix#5820

Open
Ajay-Satish-01 wants to merge 2 commits into
SQLMesh:mainfrom
Ajay-Satish-01:feat/local_tz
Open

tz_issue_fix#5820
Ajay-Satish-01 wants to merge 2 commits into
SQLMesh:mainfrom
Ajay-Satish-01:feat/local_tz

Conversation

@Ajay-Satish-01
Copy link
Copy Markdown

Description

Solves #5673

  • Adds timezone-aware parsing for relative CLI/API start, end, and execution-time values (e.g. --start "2 weeks ago"), anchored to local calendar-day midnight in a configured IANA timezone instead of UTC.
  • --time-zone CLI flag on plan, render, evaluate, run, audit, and check_intervals (overrides config)
    time_zone config (optional, IANA-validated; UTC is treated as unset)
  • Precedence: CLI > config > UTC
  • Relative parsing: day-or-larger relatives ("1 week ago", "today", etc.) use local midnight in the configured zone; sub-day relatives ("2 hours ago") are unchanged
  • Macro variables: @start_tstz / @end_tstz reflect the correct UTC instant; @start_ds / @end_ds use the local calendar date only when bounds came from relative strings (via localize_start_ds / localize_end_ds); incremental backfill intervals keep UTC-based @start_ds / @end_ds
  • Docs updated in macro_variables.md
  • Java 24+ Spark: skip @pytest.mark.pyspark tests and raise a clear ConfigError when Spark cannot start on unsupported JDK versions

Test Plan

  • pytest tests/utils/test_date.py — relative parsing (LA/Tokyo), date_dict, DST spring/fall-back, hour-grain ignores timezone, interval bounds stay UTC, absolute dates stay UTC
  • pytest tests/core/test_context.py -k "time_zone or render_relative or render_absolute or backfill_uses_utc or plan_rejects_invalid"
  • pytest tests/core/test_plan.py::test_plan_relative_dates_with_time_zone
  • pytest tests/core/test_config.py::test_config_time_zone
  • pytest tests/cli/test_cli.py::test_plan_accepts_time_zone_option tests/cli/test_cli.py::test_plan_rejects_invalid_time_zone
  • pytest tests/integrations/jupyter/test_magics.py::test_evaluate — Jupyter magic with no execution_time
  • pre-commit run mypy --all-files
  • PySpark tests skip cleanly on Java 24+ (local Java 26 verified)

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

Signed-off-by: Ajay-Satish-01 <ajay.satishpriya@gmail.com>
@Ajay-Satish-01
Copy link
Copy Markdown
Author

@StuffbyYuki, please review this PR and let me know if anything is required

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.

1 participant