Skip to content

fix: prevent get_removal_interval from returning invalid interval#3879

Merged
tobymao merged 2 commits intomainfrom
toby/get_removal_interval
Feb 25, 2025
Merged

fix: prevent get_removal_interval from returning invalid interval#3879
tobymao merged 2 commits intomainfrom
toby/get_removal_interval

Conversation

@tobymao
Copy link
Copy Markdown
Contributor

@tobymao tobymao commented Feb 21, 2025

if your partial restate a daily model -> monthly, (2024-02-15, 2024-02-20), get_removal_interval returned an interval where start > end. this ensures get_removal_interval only returns valid intervals.

@tobymao tobymao requested a review from izeigerman February 21, 2025 00:26
@tobymao tobymao force-pushed the toby/get_removal_interval branch 4 times, most recently from eabd032 to e9f37da Compare February 21, 2025 06:21
@tobymao tobymao requested a review from eakmanrq February 21, 2025 06:40
@tobymao tobymao force-pushed the toby/get_removal_interval branch from 9d98fb8 to 0f96c9e Compare February 22, 2025 03:59
Comment thread sqlmesh/core/snapshot/definition.py Outdated
@tobymao tobymao force-pushed the toby/get_removal_interval branch 5 times, most recently from b37ff4d to ba97893 Compare February 24, 2025 20:51
Comment thread sqlmesh/core/plan/builder.py Outdated
Comment thread sqlmesh/core/plan/builder.py Outdated

if not restating_parents and snapshot.name not in restate_models:
continue
if not removal_interval:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't look correct. What if removal_interval is empty, but restating_parents is not?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be

if not possible_intervals

instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this used to be true before interval expansion, because we wanted to have daily parents restate, but not the monthly. i think this doesn't make sense anymore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated

self._context_diff.snapshots[s] for s in snapshot.parents if s in restatements
]

if not restating_parents and snapshot.name not in restate_models:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we do

removal_interval = snapshot.get_removal_interval(

after this check and not before?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Btw, this check doesn't seem useful, since restating_parents doesn't filter out non-incremental models. So restating_models might be non-empty, but then possible_intervals will be empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

possible_intervals can be empty because parents are full, but get_removal_interval should always exist with expansion

@tobymao tobymao force-pushed the toby/get_removal_interval branch 3 times, most recently from 4ecff8d to 0aeb1a9 Compare February 25, 2025 03:15
if your partial restate a daily model -> monthly, (2024-02-15,
2024-02-20), get_removal_interval returned an interval where start >
end. this ensures get_removal_interval only returns valid intervals.
@tobymao tobymao force-pushed the toby/get_removal_interval branch from 0aeb1a9 to 84df3ce Compare February 25, 2025 05:43
@tobymao tobymao enabled auto-merge (squash) February 25, 2025 05:43
@tobymao tobymao merged commit f01e9f2 into main Feb 25, 2025
@tobymao tobymao deleted the toby/get_removal_interval branch February 25, 2025 05:52
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