Skip to content

Feat!: print auto-restatement triggers in debug console #4980

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

Merged
merged 13 commits into from
Aug 20, 2025

Conversation

treysp
Copy link
Contributor

@treysp treysp commented Jul 16, 2025

During a run, models are usually evaluated because their cron has elapsed. However, any model that is auto-restated will cause all its children to be evaluated as well.

Currently, SQLMesh does not indicate whether being downstream of an auto-restatement caused a model to be evaluated. This PR adds that information to the debug console.

Example

  • Sushi example project
  • Auto-restated models items, order_items, and waiter_revenue_by_day
  • Results (top to bottom in sample output)
    • items is its own trigger
    • order_items is its own trigger
    • waiter_revenue_by_day is its own trigger
    • top_waiters is downstream of of all three, but its immediate parent is waiter_revenue_by_day
    • All the rest have both items and order_items as immediate parents so are triggered by both

Output other than triggers (e.g., batch=0 | duration=1s) omitted for brevity

❯ sqlmesh --debug --gateway duckdb_persistent run                                  
[14:08:48] Starting evaluation for 12 snapshots                                                                                                                                                                                          console.py:3781
  Evaluating "duckdb"."sushi"."items"                                                                                                                                                                                           console.py:3781
  Evaluated "duckdb"."sushi"."items" | auto_restatement_triggers=["duckdb"."sushi"."items"]                                                               console.py:3781
  Evaluating "duckdb"."sushi"."order_items"                                                                                                                                                                                     console.py:3781
  Evaluated "duckdb"."sushi"."order_items" | auto_restatement_triggers=["duckdb"."sushi"."order_items"]                                                  console.py:3781
  Evaluating "duckdb"."sushi"."waiter_revenue_by_day"                                                                                                                                                                           console.py:3781
  Evaluated "duckdb"."sushi"."waiter_revenue_by_day" | auto_restatement_triggers=["duckdb"."sushi"."waiter_revenue_by_day"]                               console.py:3781
  Evaluating "duckdb"."sushi"."top_waiters"                                                                                                                                                                                     console.py:3781
  Evaluated "duckdb"."sushi"."top_waiters" | auto_restatement_triggers=["duckdb"."sushi"."waiter_revenue_by_day"]                                         console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_by_day"                                                                                                                                                                         console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_by_day" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]             console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_lifetime"                                                                                                                                                                       console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_lifetime" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]           console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_lifetime"                                                                                                                                                                       console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_lifetime" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]           console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_lifetime"                                                                                                                                                                       console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_lifetime" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]           console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_lifetime"                                                                                                                                                                       console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_lifetime" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]           console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_lifetime"                                                                                                                                                                       console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_lifetime" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]           console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_lifetime"                                                                                                                                                                       console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_lifetime" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]           console.py:3781
  Evaluating "duckdb"."sushi"."customer_revenue_lifetime"                                                                                                                                                                       console.py:3781
  Evaluated "duckdb"."sushi"."customer_revenue_lifetime" | auto_restatement_triggers=["duckdb"."sushi"."order_items", "duckdb"."sushi"."items"]           console.py:3781
  Stopping evaluation with success=True                                                                                                                                                                                         console.py:3781
  Run finished for environment 'prod'     

@treysp treysp force-pushed the trey/auto-restate-triggers branch from 828ab26 to 1230edb Compare July 16, 2025 20:52
@erindru
Copy link
Collaborator

erindru commented Jul 16, 2025

Nice, I think this will help a lot with debugging "why do I have a heap of changed models, I didnt change anything"-type questions

@treysp treysp force-pushed the trey/auto-restate-triggers branch from 1230edb to 37f6fa4 Compare July 22, 2025 20:18
@treysp treysp changed the title Feat: print auto-restated trigger of model evaluation in debug console Feat!: print auto-restated trigger of model evaluation in debug console Jul 22, 2025
@treysp treysp force-pushed the trey/auto-restate-triggers branch 2 times, most recently from a01cb9f to 22c272c Compare August 6, 2025 02:56
@treysp treysp changed the title Feat!: print auto-restated trigger of model evaluation in debug console Feat!: print triggers of model evaluation in debug console Aug 6, 2025
@treysp treysp force-pushed the trey/auto-restate-triggers branch 3 times, most recently from d385595 to 0ecfb43 Compare August 6, 2025 17:37
@treysp treysp marked this pull request as ready for review August 6, 2025 18:04
@treysp treysp force-pushed the trey/auto-restate-triggers branch from 0ecfb43 to e8127db Compare August 7, 2025 13:54
@treysp treysp force-pushed the trey/auto-restate-triggers branch from e8127db to 9c44a32 Compare August 12, 2025 17:59
@treysp treysp changed the title Feat!: print triggers of model evaluation in debug console Feat!: print auto-restatement triggers in debug console Aug 12, 2025
@treysp treysp force-pushed the trey/auto-restate-triggers branch 8 times, most recently from 4eb6586 to f7e3c69 Compare August 14, 2025 20:18
@treysp treysp force-pushed the trey/auto-restate-triggers branch from f7e3c69 to e0b56b9 Compare August 20, 2025 17:31
@treysp treysp force-pushed the trey/auto-restate-triggers branch from e0b56b9 to a8fb199 Compare August 20, 2025 20:46
@treysp treysp merged commit eb17e24 into main Aug 20, 2025
27 of 28 checks passed
@treysp treysp deleted the trey/auto-restate-triggers branch August 20, 2025 21:18
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.

5 participants