Skip to content

Commit f28341a

Browse files
andymadsontreysp
andauthored
Update CLI documentation descriptions to match current output format (#4183)
Co-authored-by: Trey Spiller <1831878+treysp@users.noreply.github.com>
1 parent 67e5e72 commit f28341a

1 file changed

Lines changed: 82 additions & 60 deletions

File tree

docs/quickstart/cli.md

Lines changed: 82 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,18 @@ $ sqlmesh plan
148148
======================================================================
149149
Successfully Ran 1 tests against duckdb
150150
----------------------------------------------------------------------
151+
151152
`prod` environment will be initialized
152153

153154
Models:
154155
└── Added:
155-
├── sqlmesh_example.seed_model
156+
├── sqlmesh_example.full_model
156157
├── sqlmesh_example.incremental_model
157-
└── sqlmesh_example.full_model
158-
Models needing backfill (missing dates):
159-
├── sqlmesh_example.full_model: 2020-01-01 - 2023-05-31
160-
├── sqlmesh_example.incremental_model: 2020-01-01 - 2023-05-31
161-
└── sqlmesh_example.seed_model: 2023-05-31 - 2023-05-31
158+
└── sqlmesh_example.seed_model
159+
Models needing backfill:
160+
├── sqlmesh_example.full_model: [full refresh]
161+
├── sqlmesh_example.incremental_model: [2020-01-01 - 2025-04-17]
162+
└── sqlmesh_example.seed_model: [full refresh]
162163
Apply - Backfill Tables [y/n]:
163164
```
164165

@@ -168,10 +169,7 @@ Line 5 describes what environments the plan will affect when applied - a new `pr
168169

169170
Lines 7-11 of the output show that SQLMesh detected three new models relative to the current empty environment.
170171

171-
Lines 12-15 list each model that will be executed by the plan, along with the date intervals that will be run. Note that `full_model` and `incremental_model` both show `2020-01-01` as their start date because:
172-
173-
1. The incremental model specifies that date in the `start` property of its `MODEL` statement and
174-
2. The full model depends on the incremental model.
172+
Lines 12-16 list each model that will be executed by the plan, along with the date intervals or refresh types. For both `full_model` and `seed_model`, it shows `[full refresh]`, while for `incremental_model` it shows a specific date range `[2020-01-01 - 2025-04-17]`. The incremental model date range begins from 2020-01-01 because the `full` model kind always fully rebuilds its table.
175173

176174
The `seed_model` date range begins on the same day the plan was made because `SEED` models have no temporality associated with them other than whether they have been modified since the previous SQLMesh plan.
177175

@@ -254,20 +252,24 @@ Line 16 asks you whether to proceed with executing the model backfills described
254252

255253
```bash linenums="1"
256254
Apply - Backfill Tables [y/n]: y
257-
Creating physical tables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3/3 • 0:00:00
258255

259-
All model versions have been created successfully
256+
Updating physical layer ━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3/3 • 0:00:00
260257

261-
[1/1] sqlmesh_example.seed_model evaluated in 0.01s
262-
[1/1] sqlmesh_example.incremental_model evaluated in 0.01s
263-
[1/1] sqlmesh_example.full_model evaluated in 0.02s
264-
Evaluating models ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3/3 • 0:00:00
258+
✔ Physical layer updated
265259

266-
All model batches have been executed successfully
260+
[1/1] sqlmesh_example.seed_model [insert seed file]
261+
0.02s
262+
[1/1] sqlmesh_example.incremental_model [insert 2020-01-01 -
263+
2025-04-17] 0.03s
264+
[1/1] sqlmesh_example.full_model [full refresh, audits ✔1]
265+
0.05s
266+
Executing model batches ━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3/3 • 0:00:00
267267

268-
Virtually Updating 'prod' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 0:00:00
268+
✔ Model batches executed
269269

270-
The target environment has been updated successfully
270+
Updating virtual layer ━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3/3 • 0:00:00
271+
272+
✔ Virtual layer updated
271273
```
272274

273275
SQLMesh performs three actions when applying the plan:
@@ -276,11 +278,13 @@ SQLMesh performs three actions when applying the plan:
276278
- Evaluating/running the models
277279
- Virtually updating the plan's target environment
278280

279-
Line 2 provides a progress bar and elapsed time for the first step of creating new model versions (very fast in this simple project). Line 4 reports that the first step has completed.
281+
Lines 2-4 show the progress and completion of the first step - updating the physical layer (creating new model versions).
282+
283+
Lines 6-11 show the execution of each model with their specific operations and timing. Line 6 shows the seed model being inserted, line 8 shows the incremental model being inserted for the specified date range, and line 10 shows the full model being processed with its audit check passing.
280284

281-
Lines 6-8 show the run time for each model in the project. Line 9 provides a progress bar and total elapsed time for the second step of evaluating the models. Line 11 reports that the second step has completed.
285+
Lines 12-14 show the progress and completion of the second step - executing model batches.
282286

283-
Line 13 provides a progress bar and total elapsed time for the third step of virtually updating the plan's target environment. Line 15 reports that the third step has completed and the `prod` environment now points to the tables created during model execution.
287+
Lines 16-18 show the progress and completion of the final step - virtually updating the plan's target environment, which makes the data available for querying.
284288

285289
You've now created a new production environment with all of history backfilled.
286290

@@ -323,63 +327,75 @@ Run `sqlmesh plan dev` to create a development environment called `dev`:
323327
$ sqlmesh plan dev
324328
======================================================================
325329
Successfully Ran 1 tests against duckdb
326-
----------------------------------------------------------------------
330+
----------------------------------------------------------------------
327331

328332
New environment `dev` will be created from `prod`
329333

334+
330335
Differences from the `prod` environment:
331336

332337
Models:
333338
├── Directly Modified:
334339
│ └── sqlmesh_example__dev.incremental_model
335340
└── Indirectly Modified:
336341
└── sqlmesh_example__dev.full_model
337-
---
338-
339-
+++
340-
341-
@@ -10,6 +10,7 @@
342342

343+
---
344+
345+
+++
346+
347+
@@ -14,6 +14,7 @@
348+
343349
SELECT
344-
id,
345-
item_id,
350+
id,
351+
item_id,
346352
+ 'z' AS new_column,
347-
event_date
353+
event_date
348354
FROM sqlmesh_example.seed_model
349355
WHERE
350-
Directly Modified: sqlmesh_example__dev.incremental_model (Non-breaking)
356+
357+
Directly Modified: sqlmesh_example__dev.incremental_model
358+
(Non-breaking)
351359
└── Indirectly Modified Children:
352-
└── sqlmesh_example__dev.full_model (Indirect Non-breaking)
360+
└── sqlmesh_example__dev.full_model (Indirect Non-breaking)
353361
Models needing backfill:
354-
└── sqlmesh_example__dev.incremental_model: [2020-01-01 - 2023-05-31]
355-
Apply - Backfill Tables [y/n]: y
362+
└── sqlmesh_example__dev.incremental_model: [2020-01-01 - 2025-04-17]
363+
Apply - Backfill Tables [y/n]:
356364
```
357365

358366
Line 6 of the output states that a new environment `dev` will be created from the existing `prod` environment.
359367

360-
Lines 8-14 summarize the differences between the modified model and the `prod` environment, detecting that we directly modified `incremental_model` and that `full_model` was indirectly modified because it selects from the incremental model. Note that the model schemas are `sqlmesh_example__dev`, indicating that they are being created in the `dev` environment.
368+
Lines 10-15 summarize the differences between the modified model and the `prod` environment, detecting that we directly modified `incremental_model` and that `full_model` was indirectly modified because it selects from the incremental model. Note that the model schemas are `sqlmesh_example__dev`, indicating that they are being created in the `dev` environment.
361369

362-
On line 28, we see that SQLMesh automatically classified the change as `Non-breaking` because it understood that the change was additive (added a column not used by `full_model`) and did not invalidate any data already in `prod`.
370+
On line 31, we see that SQLMesh automatically classified the change as `Non-breaking` because it understood that the change was additive (added a column not used by `full_model`) and did not invalidate any data already in `prod`.
363371

364372
Enter `y` at the prompt and press `Enter` to apply the plan and execute the backfill:
365373

366374
```bash linenums="1"
367375
Apply - Backfill Tables [y/n]: y
368-
Creating physical tables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 2/2 • 0:00:00
369376

370-
Model versions created successfully
377+
Updating physical layer ━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 2/2 • 0:00:00
378+
379+
✔ Physical layer updated
371380

372-
[1/1] sqlmesh_example__dev.incremental_model evaluated in 0.01s
373-
Evaluating models ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 1/1 • 0:00:00
381+
[1/1] sqlmesh_example__dev.incremental_model [insert 2020-01-01 -
382+
2025-04-17] 0.03s
383+
Executing model batches ━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 1/1 • 0:00:00
374384

375-
Model batches executed successfully
385+
Model batches executed
376386

377-
Virtually Updating 'dev' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 0:00:00
387+
Updating virtual layer ━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 2/2 • 0:00:00
378388

379-
Target environment updated successfully
389+
✔ Virtual layer updated
380390
```
381391

382-
Line 6 of the output shows that SQLMesh applied the change and evaluated `sqlmesh_example__dev.incremental_model`.
392+
Lines 3-5 show the progress and completion of updating the physical layer.
393+
394+
Line 7 shows that SQLMesh applied the change and evaluated `sqlmesh_example__dev.incremental_model` for the date range from 2020-01-01 to 2025-04-17.
395+
396+
Lines 9-11 show the progress and completion of executing model batches.
397+
398+
Lines 13-15 show the progress and completion of updating the virtual layer.
383399

384400
SQLMesh did not need to backfill anything for the `full_model` since the change was `Non-breaking`.
385401

@@ -431,39 +447,45 @@ Enter `y` and press `Enter` at the `Apply - Virtual Update [y/n]:` prompt to app
431447
$ sqlmesh plan
432448
======================================================================
433449
Successfully Ran 1 tests against duckdb
434-
----------------------------------------------------------------------
450+
----------------------------------------------------------------------
451+
435452
Differences from the `prod` environment:
436453

437454
Models:
438455
├── Directly Modified:
439456
│ └── sqlmesh_example.incremental_model
440457
└── Indirectly Modified:
441458
└── sqlmesh_example.full_model
442-
---
443-
444-
+++
445-
446-
@@ -10,6 +10,7 @@
447459

460+
---
461+
462+
+++
463+
464+
@@ -14,6 +14,7 @@
465+
448466
SELECT
449-
id,
450-
item_id,
467+
id,
468+
item_id,
451469
+ 'z' AS new_column,
452-
event_date
470+
event_date
453471
FROM sqlmesh_example.seed_model
454472
WHERE
455-
Directly Modified: sqlmesh_example.incremental_model (Non-breaking)
473+
474+
Directly Modified: sqlmesh_example.incremental_model (Non-breaking)
456475
└── Indirectly Modified Children:
457476
└── sqlmesh_example.full_model (Indirect Non-breaking)
458477
Apply - Virtual Update [y/n]: y
459-
Virtually Updating 'prod' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 0:00:00
460478

461-
Target environment updated successfully
479+
SKIP: No physical layer updates to perform
480+
481+
SKIP: No model batches to execute
482+
483+
Updating virtual layer ━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 2/2 • 0:00:00
462484

463-
Virtual Update executed successfully
485+
Virtual layer updated
464486
```
465487

466-
Note that a backfill was not necessary and only a Virtual Update occurred.
488+
Note that a backfill was not necessary and only a Virtual Update occurred, as indicated by the "SKIP: No physical layer updates to perform" and "SKIP: No model batches to execute" messages. This is because the changes were already calculated and executed in the `dev` environment, and SQLMesh is smart enough to recognize that it only needs to update the virtual references to the existing tables rather than recomputing everything.
467489

468490
### 5.2 Validate updates in prod
469491
Double-check that the data updated in `prod` by running `sqlmesh fetchdf "select * from sqlmesh_example.incremental_model"`:
@@ -490,4 +512,4 @@ From here, you can:
490512
* [Learn more about SQLMesh CLI commands](../reference/cli.md)
491513
* [Set up a connection to a database or SQL engine](../guides/connections.md)
492514
* [Learn more about SQLMesh concepts](../concepts/overview.md)
493-
* [Join our Slack community](https://tobikodata.com/slack)
515+
* [Join our Slack community](https://tobikodata.com/slack)

0 commit comments

Comments
 (0)