Skip to content

Commit ff0219c

Browse files
authored
Merge branch 'main' into add_fabric_warehouse
2 parents 1bbe90e + 82f2447 commit ff0219c

161 files changed

Lines changed: 9475 additions & 1409 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/concepts/models/python_models.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ def execute(
163163
) -> pd.DataFrame:
164164

165165
# pre-statement
166-
context.fetchdf("SET GLOBAL parameter = 'value';")
166+
context.engine_adapter.execute("SET GLOBAL parameter = 'value';")
167167

168168
# post-statement requires using `yield` instead of `return`
169169
yield pd.DataFrame([
170170
{"id": 1, "name": "name"}
171171
])
172172

173173
# post-statement
174-
context.fetchdf("CREATE INDEX idx ON example.pre_post_statements (id);")
174+
context.engine_adapter.execute("CREATE INDEX idx ON example.pre_post_statements (id);")
175175
```
176176

177177
## Optional on-virtual-update statements

docs/guides/configuration.md

Lines changed: 124 additions & 28 deletions
Large diffs are not rendered by default.

docs/guides/vscode.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ Because the VSCode extension establishes a long-running process connected to the
149149

150150
Therefore, we do not recommend using DuckDB as a state store with the VSCode extension.
151151

152+
### Environment variables
153+
154+
The VSCode extension is based on a [language server](https://en.wikipedia.org/wiki/Language_Server_Protocol) that runs in the background as a separate process. When the VSCode extension starts the background language server, the server inherits environment variables from the environment where you started VSCode. The server does *not* inherit environment variables from your terminal instance in VSCode, so it may not have access to variables you use when calling SQLMesh from the CLI.
155+
156+
If you have environment variables that are needed by the context and the language server, you can use one of these approaches to pass variables to the language server:
157+
158+
- Open VSCode from a terminal that has the variables set
159+
- Use environment variables pulled from somewhere else dynamically (e.g. a `.env` file) in your config
160+
- Set the environment variables in the python environment that the extension uses. You can find detailed instructions [here](https://code.visualstudio.com/docs/python/environments#_environment-variables)
161+
152162
### Python environment woes
153163

154164
The most common problem is the extension not using the correct Python interpreter.

docs/reference/cli.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -419,19 +419,31 @@ Usage: sqlmesh render [OPTIONS] MODEL
419419
Render a model's query, optionally expanding referenced models.
420420
421421
Options:
422-
-s, --start TEXT The start datetime of the interval for which this
423-
command will be applied.
424-
-e, --end TEXT The end datetime of the interval for which this
425-
command will be applied.
426-
--execution-time TEXT The execution time (defaults to now).
427-
--expand TEXT Whether or not to expand materialized models
428-
(defaults to False). If True, all referenced models
429-
are expanded as raw queries. Multiple model names can
430-
also be specified, in which case only they will be
431-
expanded as raw queries.
432-
--dialect TEXT The SQL dialect to render the query as.
433-
--no-format Disable fancy formatting of the query.
434-
--help Show this message and exit.
422+
-s, --start TEXT The start datetime of the interval for which
423+
this command will be applied.
424+
-e, --end TEXT The end datetime of the interval for which this
425+
command will be applied.
426+
--execution-time TEXT The execution time (defaults to now).
427+
--expand TEXT Whether or not to expand materialized models
428+
(defaults to False). If True, all referenced
429+
models are expanded as raw queries. Multiple
430+
model names can also be specified, in which case
431+
only they will be expanded as raw queries.
432+
--dialect TEXT The SQL dialect to render the query as.
433+
--no-format Disable fancy formatting of the query.
434+
--max-text-width INTEGER The max number of characters in a segment before
435+
creating new lines in pretty mode.
436+
--leading-comma Determines whether or not the comma is leading
437+
or trailing in select expressions. Default is
438+
trailing.
439+
--normalize-functions TEXT Whether or not to normalize all function names.
440+
Possible values are: 'upper', 'lower'
441+
--indent INTEGER Determines the indentation size in a formatted
442+
string.
443+
--pad INTEGER Determines the pad size in a formatted string.
444+
--normalize Whether or not to normalize identifiers to
445+
lowercase.
446+
--help Show this message and exit.
435447
```
436448

437449
## rewrite

docs/reference/notebook.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import sqlmesh
2929
If desired, you can create the [quickstart example project](../quick_start.md) with the Python `init_example_project` function. The function requires a default SQL dialect for the project's models; this example uses `snowflake`:
3030

3131
```python
32-
from sqlmesh.cli.example_project import init_example_project
32+
from sqlmesh.cli.project_init import init_example_project
3333

34-
init_example_project("path_to_project_directory", dialect="snowflake")
34+
init_example_project("path_to_project_directory", engine_type="snowflake")
3535
```
3636

3737
Alternatively, create the project with a notebook magic:
@@ -201,6 +201,9 @@ options:
201201
```
202202
%render [--start START] [--end END] [--execution-time EXECUTION_TIME]
203203
[--expand EXPAND] [--dialect DIALECT] [--no-format]
204+
[--normalize] [--pad PAD] [--indent INDENT]
205+
[--normalize-functions NORMALIZE_FUNCTIONS] [--leading-comma]
206+
[--max-text-width MAX_TEXT_WIDTH]
204207
model
205208
206209
Renders a model's query, optionally expanding referenced models.
@@ -220,6 +223,17 @@ options:
220223
models are expanded as raw queries.
221224
--dialect DIALECT SQL dialect to render.
222225
--no-format Disable fancy formatting of the query.
226+
--normalize Whether or not to normalize identifiers to lowercase.
227+
--pad PAD Determines the pad size in a formatted string.
228+
--indent INDENT Determines the indentation size in a formatted string.
229+
--normalize-functions NORMALIZE_FUNCTIONS
230+
Whether or not to normalize all function names.
231+
Possible values are: 'upper', 'lower'
232+
--leading-comma Determines whether or not the comma is leading or
233+
trailing in select expressions. Default is trailing.
234+
--max-text-width MAX_TEXT_WIDTH
235+
The max number of characters in a segment before
236+
creating new lines in pretty mode.
223237
```
224238

225239
#### dag

examples/sushi/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,17 @@
128128
)
129129

130130

131-
environment_suffix_config = Config(
131+
environment_suffix_table_config = Config(
132132
default_connection=DuckDBConnectionConfig(),
133133
model_defaults=model_defaults,
134134
environment_suffix_target=EnvironmentSuffixTarget.TABLE,
135135
)
136136

137+
environment_suffix_catalog_config = environment_suffix_table_config.model_copy(
138+
update={
139+
"environment_suffix_target": EnvironmentSuffixTarget.CATALOG,
140+
}
141+
)
137142

138143
CATALOGS = {
139144
"in_memory": ":memory:",

examples/sushi/models/customers.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ LEFT JOIN (
3737
@ADD_ONE(1) AS another_column,
3838
FROM current_marketing_outer
3939
)
40-
SELECT * FROM current_marketing
40+
SELECT current_marketing.* FROM current_marketing WHERE current_marketing.customer_id != 100
4141
) AS m
4242
ON o.customer_id = m.customer_id
4343
LEFT JOIN raw.demographics AS d
4444
ON o.customer_id = d.customer_id
45+
WHERE sushi.orders.customer_id > 0

0 commit comments

Comments
 (0)