sqlmesh icon indicating copy to clipboard operation
sqlmesh copied to clipboard

Support cron_tz in model_defaults for project-wide timezone configuration

Open lafirm opened this issue 10 months ago • 2 comments

Feature Request

Add support for cron_tz in the model_defaults section of config.yaml to allow setting a default timezone for all models in a project.

Use Case

In projects where all models use the same timezone for cron scheduling, it's repetitive and error-prone to specify the timezone in every individual model definition. A project-wide default would significantly reduce configuration duplication and maintenance overhead.

Current Behavior

Currently, cron_tz must be specified in each individual model's MODEL() definition:

MODEL (
  name my_schema.my_model,
  cron: '0 * * * *',
  cron_tz 'Europe/London',
);

When attempting to set it in model_defaults, SQLMesh returns an error:

Error: 'cron_tz' is not a valid model default configuration key. Please remove it from the model_defaults specification in your config file.

Desired Behavior

Allow cron_tz to be specified in model_defaults:

model_defaults:
  dialect: trino
  start: '2025-01-01'
  kind: VIEW
  cron: '0 * * * *'
  cron_tz: 'Europe/London'  # Should be valid here
  interval_unit: 'hour'

lafirm avatar Jan 14 '26 07:01 lafirm

As a temporary workaround (until this feature is implemented natively), you can configure it using a Python-based Config, as described in the documentation:

https://sqlmesh.readthedocs.io/en/stable/guides/configuration/#python

For example:

from sqlmesh.core.config import Config, ModelDefaultsConfig


class ExtendedModelDefaultsConfig(ModelDefaultsConfig):
    cron_tz: str


config = Config(
    model_defaults=ExtendedModelDefaultsConfig(
        cron_tz='America/New_York',
    ),
)

coshy0163 avatar Feb 27 '26 16:02 coshy0163

As a temporary workaround (until this feature is implemented natively), you can configure it using a Python-based Config, as described in the documentation:

Thanks @coshy0163, but unfortunately I can't implement this workaround in our project at this time

lafirm avatar Mar 11 '26 05:03 lafirm