You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/integrations/airflow.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ The name of the module file can be arbitrary, but we recommend something descrip
28
28
**Note**: The name of the Engine operator is the only mandatory parameter needed for `sqlmesh.schedulers.airflow.integration.SQLMeshAirflow`. Currently supported engines are listed in the [Engine support](#engine-support) section.
29
29
30
30
## SQLMesh client configuration
31
-
In your SQLMesh repository, create the following configuration:
31
+
In your SQLMesh repository, create the following configuration within config.py:
32
32
```python linenums="1"
33
33
from sqlmesh.core.config import Config, AirflowSchedulerConfig
SQLMesh provides support for the dbt project structure.
3
+
SQLMesh has native support for running dbt projects. This featuring is currently under development. You can view the development backlog [here](https://github.com/orgs/TobikoData/projects/1/views/3). If you are interested in this feature, we encourage you to try it with your dbt projects and submit issues here (https://github.com/TobikoData/sqlmesh/issues), so we can make it more robust.
4
4
5
-
## Importing a dbt project
5
+
## Getting Started
6
+
### Importing a dbt project
6
7
7
-
SQLMesh supports reading an existing dbt project in order to create a new project. To initialize SQLMesh to do so, run the following command within the project root:
8
+
A SQLMesh project can be configured during initialization to read from a dbt formatted project. To do so, run the following command within the dbt project root:
8
9
9
10
```bash
10
11
$ sqlmesh init -t dbt
11
12
```
12
13
13
-
The target in your `profiles.yml` file will be used by default. To use a different target, run the command above with the `--connection TARGET_NAME` command line option.
14
+
The target specified in your `profiles.yml` file will be used by default. The target can be changed at anytime.
14
15
15
16
**Note:** Models require a start date for backfilling data through use of the `start` configuration parameter. Start can be defined for each model, or globally in the `dbt_project.yml` file as follows:
16
17
@@ -19,29 +20,36 @@ The target in your `profiles.yml` file will be used by default. To use a differe
19
20
> +start: Jan 1 2000
20
21
```
21
22
22
-
## Workflow differences between SQLMesh and dbt
23
+
### Running SQLMesh
24
+
25
+
Link to how to normally run sqlmesh here (plan, run). Continue to use your dbt format.
26
+
27
+
### Workflow differences between SQLMesh and dbt
23
28
24
29
The following are considerations when importing a dbt project:
25
30
26
31
* SQLMesh will detect and deploy new or modified seeds as part of running the `plan` command and applying changes. There is no separate seed command. Refer to [seed models](/concepts/models/seed_models) for more information.
27
-
* The `plan` command dynamically creates environments, and therefore environments do not need to be hardcoded into your `profiles.yml` file as targets. To get the most out of SQLMesh, point your default target at the production target, and let SQLMesh handle the rest for you.
32
+
* The `plan` command dynamically creates environments, and therefore environments do not need to be hardcoded into your `profiles.yml` file as targets. To get the most out of SQLMesh, point your profile target at the production target, and let SQLMesh handle the rest for you.
28
33
* dbt tests are considered [audits](/concepts/audits) in SQLMesh. SQLMesh tests are [unit tests](/concepts/tests), which test query logic before applying a plan.
34
+
* SQLMesh's incremental models track which intervals have been filled and automatically detects and fills interval gaps. dbt does not support intervals and their recommended incremental logic is not compatible, requiring small tweaks to the models (don't worry dbt compatibility is maintained).
29
35
30
36
## How to use SQLMesh incremental models within dbt
31
37
32
-
SQLMesh uses true incremental models, which are capable of detecting and backfilling any missing intervals. dbt's incremental logic does not support intervals, and is not compatible with SQLMesh.
38
+
SQLMesh's incremental models track uses true incremental models, which are capable of detecting and backfilling any missing intervals. dbt's incremental logic does not support intervals, and is not compatible with SQLMesh.
33
39
34
40
### Mapping dbt incremental to SQLMesh incremental
35
-
SQLMesh ensures [idempotent](/concepts/glossary#idempotency) incremental loads through the use of merge (sqlmesh calls this `incremental_by_unique_key`) and insert-overwrite (sqlmesh calls this `incremental_by_time`) incremental strategies:
41
+
SQLMesh supports [idempotent](/concepts/glossary#idempotency) incremental loads through the use of merge (sqlmesh calls this `incremental_by_unique_key`) and insert-overwrite/delete+insert (sqlmesh calls this `incremental_by_time`) incremental strategies. Append is not currently supported and not recommended due to not being idempotent.
42
+
43
+
44
+
45
+
#### Merge modifications
36
46
37
-
1. For merge, specify the `unique_key` configuration field containing the name of the model's unique key column to use. Append is not idempotent, and therefore is not supported.
38
-
2. For insert-overwrite, add a `time_column` configuration field with the value of the name of the model's time column to use.
39
47
40
-
### Model modifications
41
48
42
-
Since SQLMesh tracks intervals to deliver true incremental behavior, the dbt incremental `WHERE` statements are not compatible with SQLMesh's incremental `WHERE` statements.
49
+
#### Insert-overwrite and delete+insert modifications
50
+
1. For insert-overwrite, add a `time_column` configuration field with the value of the name of the model's time column to use.
43
51
44
-
In order to maintain backwards compatibility with dbt, SQLMesh will ignore any jinja blocks using `{% if is_incremental() %}`, and will instead ask you define a new jinja block gated by `{% if sqlmesh is defined %}`.
52
+
As mentioned in the workflow changes, a small model tweak is required. In order to maintain backwards compatibility with dbt, SQLMesh will ignore any jinja blocks using `{% if is_incremental() %}`, and will instead ask you define a new jinja block gated by `{% if sqlmesh is defined %}`.
45
53
46
54
For example, for incremental by time using a ds `time_column`:
47
55
@@ -54,6 +62,69 @@ For example, for incremental by time using a ds `time_column`:
54
62
55
63
For more information about how to use different time types or unique keys, refer to [incremental model kinds](/concepts/models/model_kinds).
56
64
65
+
### Unit Tests
66
+
This is the same as sqlmesh unit tests...link to that. Yes, they go in the same folder as dbt tests (audits).
See airflow docs for AirflowSchedulerConfig configuration options.
78
+
79
+
80
+
## Support dbt jinja methods
81
+
82
+
The majority of dbt jinja methods are supported. Here is a list (it'd be nice if the list was multiple columns so it wasn't so long):
83
+
84
+
- adapter
85
+
- as_bool
86
+
- as_native
87
+
- as_number
88
+
- as_text
89
+
- api
90
+
- builtins
91
+
- config
92
+
- env_var
93
+
- exceptions
94
+
- from_yaml
95
+
- is_incremental (always returns false, see incremental section)
96
+
- load_result
97
+
- log
98
+
- modules
99
+
- print
100
+
- project_name
101
+
- ref
102
+
- return
103
+
- run_query
104
+
- schema
105
+
- set
106
+
- source
107
+
- statement
108
+
- target
109
+
- this
110
+
- to_yaml
111
+
- var
112
+
- zip
113
+
57
114
## Unsupported dbt features
58
115
59
-
While SQLMesh can read dbt packages, it does not currently support managing those packages. Continue to use dbt deps and dbt clean to update, add, or remove packages. For more information, refer to [dbt deps](https://docs.getdbt.com/reference/commands/deps).
116
+
SQLMesh is continuously adding more dbt features
117
+
118
+
Not an exhaustive list, but trying to catch the major features
119
+
120
+
dbt deps
121
+
- While SQLMesh can read dbt packages, it does not currently support managing those packages. Continue to use dbt deps and dbt clean to update, add, or remove packages. For more information, refer to [dbt deps](https://docs.getdbt.com/reference/commands/deps).
122
+
123
+
dbt test not currently supported, but in development
124
+
125
+
dbt docs is not supported, snapshots not supported
126
+
127
+
## Missing something you need?
128
+
129
+
Submit an issue here (https://github.com/TobikoData/sqlmesh/issues) and we'll look into it
0 commit comments