-
Notifications
You must be signed in to change notification settings - Fork 321
Description
Actual behavior:
Given a model
MODEL (
name sqlmesh_example.demo,
kind INCREMENTAL_BY_TIME_RANGE (
time_column day,
batch_size 1
),
start '2025-12-20'
);
SELECT @start_ds AS day;
When running sqlmesh plan --execution-time '2025-12-26', the intervals between the model's start date and the execution time are filled (in this case 2025-12-20 until 2025-12-25) are created as expected.
However, subsequently running sqlmesh plan --execution-time '2025-12-28', sqlmesh does nothing, just stating:
No changes to plan: project files match the prod environment
This happens only in prod. If I do the same in dev environments, then the intervals 2025-12-26 and 2025-12-27 are filled as expected.
Expected behavior:
Since I explicitly pass --execution-time '2025-12-28', I expect the intervals 2025-12-26 and 2025-12-27 to be filled.
If this is somehow intended behavior, then at least I expect:
- dev and prod to behave the same way
- the documentation should mention this gotcha
Self-contained reproduction script:
# create temp dir for sqlmesh project
cd $(mktemp -d)
python -m venv .venv
source .venv/bin/activate
pip install sqlmesh
# create empty sqlmesh project with all defaults (duckdb)
yes 1 | sqlmesh init -t EMPTY
# create model
echo "\
MODEL (
name sqlmesh_example.demo,
kind INCREMENTAL_BY_TIME_RANGE (
time_column day,
batch_size 1
),
start '2025-12-20'
);
SELECT @start_ds AS day;
" > models/demo.sql
echo "Running in dev with --execution-time '2025-12-22'"
sqlmesh plan dev --execution-time '2025-12-22' --auto-apply
echo "Looking at the data:"
sqlmesh fetchdf "select * from sqlmesh_example__dev.demo"
# Note: this prints (as expected):
# day
# 0 2025-12-20
# 1 2025-12-21
echo "Running in dev with --execution-time '2025-12-24'"
sqlmesh plan dev --execution-time '2025-12-24' --auto-apply
echo "Looking at the data:"
sqlmesh fetchdf "select * from sqlmesh_example__dev.demo"
# Note: this prints (as expected):
# day
# 0 2025-12-20
# 1 2025-12-21
# 0 2025-12-22
# 1 2025-12-23
echo "Running in prod with --execution-time '2025-12-26'"
sqlmesh plan --execution-time '2025-12-26' --auto-apply
echo "Looking at the data:"
sqlmesh fetchdf "select * from sqlmesh_example.demo"
# Note: this prints (as expected):
# day
# 0 2025-12-20
# 1 2025-12-21
# 0 2025-12-22
# 1 2025-12-23
# 0 2025-12-24
# 1 2025-12-25
echo "Running in prod with --execution-time '2025-12-28'. Should update the model (but doesn't)!"
sqlmesh plan --execution-time '2025-12-28' --auto-apply
echo "Note that the above incorrectly prints:"
echo " No changes to plan: project files match the prod environment"
echo ""
echo "Notice the model still shows the only the days 20 to 25:"
sqlmesh fetchdf "select * from sqlmesh_example.demo"