Skip to content

Commit 7e59768

Browse files
committed
Move explain section up
1 parent 8489d34 commit 7e59768

File tree

1 file changed

+73
-73
lines changed

1 file changed

+73
-73
lines changed

docs/quickstart/cli.md

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,78 @@ SQLMesh's key actions are creating and applying *plans* to *environments*. At th
288288

289289
After SQLMesh creates a plan, it summarizes the breaking and non-breaking changes so you can understand what will happen if you apply the plan. It will prompt you to "backfill" data to apply the plan. (In this context, backfill is a generic term for updating or adding to a table's data, including an initial load or full refresh.)
290290

291+
??? info "Learn more about a plan's actions: `sqlmesh plan --explain`"
292+
293+
Before applying a plan, you can view a detailed description of the actions it will take by passing the explain flag in your `sqlmesh plan` command:
294+
295+
```bash
296+
sqlmesh plan --explain
297+
```
298+
299+
Passing the explain flag for the quickstart example project above adds the following information to the output:
300+
301+
```bash
302+
Explained plan
303+
├── Validate SQL and create physical layer tables and views if they do not exist
304+
│ ├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
305+
│ │ ├── Dry run model query without inserting results
306+
│ │ └── Create table if it doesn't exist
307+
│ ├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
308+
│ │ ├── Dry run model query without inserting results
309+
│ │ └── Create table if it doesn't exist
310+
│ └── sqlmesh_example.incremental_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__1880815781
311+
│ ├── Dry run model query without inserting results
312+
│ └── Create table if it doesn't exist
313+
├── Backfill models by running their queries and run standalone audits
314+
│ ├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
315+
│ │ └── Fully refresh table
316+
│ ├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
317+
│ │ ├── Fully refresh table
318+
│ │ └── Run 'assert_positive_order_ids' audit
319+
│ └── sqlmesh_example.incremental_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__1880815781
320+
│ └── Fully refresh table
321+
└── Update the virtual layer for environment 'prod'
322+
└── Create or update views in the virtual layer to point at new physical tables and views
323+
├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
324+
├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
325+
└── sqlmesh_example.incremental_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__1880815781
326+
```
327+
328+
The explanation has three top-level sections, corresponding to the three types of actions a plan takes:
329+
330+
- Validate SQL and create physical layer tables and views if they do not exist
331+
- Backfill models by running their queries and run standalone audits
332+
- Update the virtual layer for environment 'prod'
333+
334+
Each section lists the affected models and provides more information about what will occur. For example, the first model in the first section is:
335+
336+
```bash
337+
├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
338+
│ ├── Dry run model query without inserting results
339+
│ └── Create table if it doesn't exist
340+
```
341+
342+
The first line shows the model name `sqlmesh_example.seed_model` and the physical layer table SQLMesh will create to store its data: `db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172`. The second and third lines tell us that in this step SQLMesh will dry-run the model query and create the physical layer table if it doesn't exist.
343+
344+
The second section describes what will occur during the backfill step. The second model in this section is:
345+
346+
```bash
347+
├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
348+
│ ├── Fully refresh table
349+
│ └── Run 'assert_positive_order_ids' audit
350+
```
351+
352+
The first line shows the model name `sqlmesh_example.full_model` and the physical layer table SQLMesh will insert the model's data into: `db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865`. The second and third lines tell us that the backfill action will fully refresh the model's physical table and run the `assert_positive_order_ids` audit.
353+
354+
The final section describes SQLMesh's action during the virtual layer update step. The first model in this section is:
355+
356+
```bash
357+
└── Create or update views in the virtual layer to point at new physical tables and views
358+
├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
359+
```
360+
361+
The virtual layer step will update the `sqlmesh_example.full_model` virtual layer view to `SELECT * FROM` the physical table `db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865`.
362+
291363
The first SQLMesh plan must execute every model to populate the production environment. Running `sqlmesh plan` will generate the plan and the following output:
292364

293365
```bash linenums="1"
@@ -428,79 +500,7 @@ Lines 12-14 show the progress and completion of the second step - executing mode
428500

429501
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.
430502

431-
??? "Learn more about the plan's actions: `sqlmesh plan --explain`"
432-
433-
Before applying a plan, you can view a detailed description of the actions it will take by passing the explain flag in your `sqlmesh plan` command:
434-
435-
```bash
436-
sqlmesh plan --explain
437-
```
438-
439-
Passing the explain flag for the quickstart example project above adds the following information to the output:
440-
441-
```bash
442-
Explained plan
443-
├── Validate SQL and create physical layer tables and views if they do not exist
444-
│ ├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
445-
│ │ ├── Dry run model query without inserting results
446-
│ │ └── Create table if it doesn't exist
447-
│ ├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
448-
│ │ ├── Dry run model query without inserting results
449-
│ │ └── Create table if it doesn't exist
450-
│ └── sqlmesh_example.incremental_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__1880815781
451-
│ ├── Dry run model query without inserting results
452-
│ └── Create table if it doesn't exist
453-
├── Backfill models by running their queries and run standalone audits
454-
│ ├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
455-
│ │ └── Fully refresh table
456-
│ ├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
457-
│ │ ├── Fully refresh table
458-
│ │ └── Run 'assert_positive_order_ids' audit
459-
│ └── sqlmesh_example.incremental_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__1880815781
460-
│ └── Fully refresh table
461-
└── Update the virtual layer for environment 'prod'
462-
└── Create or update views in the virtual layer to point at new physical tables and views
463-
├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
464-
├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
465-
└── sqlmesh_example.incremental_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__1880815781
466-
```
467-
468-
The explanation has three top-level sections, corresponding to the three types of actions a plan takes:
469-
470-
- Validate SQL and create physical layer tables and views if they do not exist
471-
- Backfill models by running their queries and run standalone audits
472-
- Update the virtual layer for environment 'prod'
473-
474-
Each section lists the affected models and provides more information about what will occur. For example, the first model in the first section is:
475-
476-
```bash
477-
├── sqlmesh_example.seed_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172
478-
│ ├── Dry run model query without inserting results
479-
│ └── Create table if it doesn't exist
480-
```
481-
482-
The first line shows the model name `sqlmesh_example.seed_model` and the physical layer table SQLMesh will create to store its data: `db.sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__2185867172`. The second and third lines tell us that in this step SQLMesh will dry-run the model query and create the physical layer table if it doesn't exist.
483-
484-
The second section describes what will occur during the backfill step. The second model in this section is:
485-
486-
```bash
487-
├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
488-
│ ├── Fully refresh table
489-
│ └── Run 'assert_positive_order_ids' audit
490-
```
491-
492-
The first line shows the model name `sqlmesh_example.full_model` and the physical layer table SQLMesh will insert the model's data into: `db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865`. The second and third lines tell us that the backfill action will fully refresh the model's physical table and run the `assert_positive_order_ids` audit.
493-
494-
The final section describes SQLMesh's action during the virtual layer update step. The first model in this section is:
495-
496-
```bash
497-
└── Create or update views in the virtual layer to point at new physical tables and views
498-
├── sqlmesh_example.full_model -> db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865
499-
```
500-
501-
The virtual layer step will update the `sqlmesh_example.full_model` virtual layer view to `SELECT * FROM` the physical table `db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__2278521865`.
502-
503-
Let's take a quick look at the project's DuckDB database file to see the objects SQLMesh created. First, we open the built-in DuckDB CLI tool with the `duckdb db.db` command, then run our two queries:
503+
Let's take a quick look at the project's DuckDB database file to see the objects SQLMesh created. First, we open the built-in DuckDB CLI tool with the `duckdb db.db` command, then run our two queries.
504504

505505
Our first query shows the three physical tables SQLMesh created in the `sqlmesh__sqlmesh_example` schema (one table for each model):
506506

0 commit comments

Comments
 (0)