Skip to content

Commit ea11179

Browse files
benfdkingtreysp
andauthored
docs: add documentation for vscode extension (#4407)
Co-authored-by: Trey Spiller <1831878+treysp@users.noreply.github.com>
1 parent 4c2d626 commit ea11179

8 files changed

Lines changed: 167 additions & 7 deletions

File tree

docs/installation.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,24 @@ pip install sqlmesh
2424
```
2525

2626
## Install extras
27-
Some SQLMesh functionality requires additional Python libraries.
27+
Some SQLMesh functionality requires additional Python libraries, which are bundled with SQLMesh via "extras".
2828

29-
`pip` will automatically install them for you if you specify the relevant name in brackets. For example, you install the SQLMesh browser UI extras with `pip install "sqlmesh[web]"`.
29+
In your `pip` command, specify the extra's name in brackets to automatically install the additional libraries. For example, you install the SQLMesh Github CI/CD bot extras with `pip install "sqlmesh[github]"`.
3030

31-
Some extras add features, like the SQLMesh browser UI or Github CI/CD bot:
31+
There are two types of extras.
32+
33+
Some extras add features, like the SQLMesh VSCode extension or Github CI/CD bot:
3234

3335
??? info "Feature extras commands"
3436
| Feature | `pip` command |
3537
| ------------------- | ------------------------------- |
36-
| Browser UI | `pip install "sqlmesh[web]"` |
38+
| VSCode extension | `pip install "sqlmesh[lsp]"` |
39+
| Github CI/CD bot | `pip install "sqlmesh[github]"` |
3740
| dbt projects | `pip install "sqlmesh[dbt]"` |
3841
| dlt projects | `pip install "sqlmesh[dlt]"` |
39-
| Github CI/CD bot | `pip install "sqlmesh[github]"` |
4042
| Slack notifications | `pip install "sqlmesh[slack]"` |
4143
| Development setup | `pip install "sqlmesh[dev]"` |
44+
| Browser UI | `pip install "sqlmesh[web]"` |
4245
| LLM SQL prompt | `pip install "sqlmesh[llm]"` |
4346

4447
Other extras are required to use specific SQL engines, like Bigquery or Postgres:
@@ -47,6 +50,7 @@ Other extras are required to use specific SQL engines, like Bigquery or Postgres
4750
| SQL engine | `pip` command |
4851
| ------------- | ------------------------------------ |
4952
| Athena | `pip install "sqlmesh[athena]"` |
53+
| Azure SQL | `pip install "sqlmesh[azuresql]"` |
5054
| Bigquery | `pip install "sqlmesh[bigquery]"` |
5155
| ClickHouse | `pip install "sqlmesh[clickhouse]"` |
5256
| Databricks | `pip install "sqlmesh[databricks]"` |
@@ -55,10 +59,11 @@ Other extras are required to use specific SQL engines, like Bigquery or Postgres
5559
| MySQL | `pip install "sqlmesh[mysql]"` |
5660
| Postgres | `pip install "sqlmesh[postgres]"` |
5761
| Redshift | `pip install "sqlmesh[redshift]"` |
62+
| RisingWave | `pip install "sqlmesh[risingwave]"` |
5863
| Snowflake | `pip install "sqlmesh[snowflake]"` |
5964
| Trino | `pip install "sqlmesh[trino]"` |
6065

61-
Multiple extras can be installed at once, as in `pip install "sqlmesh[web,slack]"`.
66+
Multiple extras can be installed at once, as in `pip install "sqlmesh[github,slack]"`.
6267

6368
## Next steps
6469

docs/quickstart/vscode.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Visual Studio Code Extension
2+
3+
!!! danger "Preview"
4+
5+
The SQLMesh Visual Studio Code extension is in preview and undergoing active development. You may encounter bugs or API incompatibilities with the SQLMesh version you are running.
6+
7+
We encourage you to try the extension and [create Github issues](https://github.com/tobikodata/sqlmesh/issues) for any problems you encounter.
8+
9+
In this guide, you'll set up the SQLMesh extension in the Visual Studio Code IDE software (which we refer to as "VSCode").
10+
11+
We'll show you the capabilities of the extension and how to troubleshoot common issues.
12+
13+
## Installation
14+
15+
### VSCode extension
16+
17+
Install the extension through the official Visual Studio [marketplace website](https://marketplace.visualstudio.com/items?itemName=tobikodata.sqlmesh) or by searching for `SQLMesh` in the VSCode "Extensions" tab.
18+
19+
Learn more about installing VSCode extensions in the [official documentation](https://code.visualstudio.com/docs/configure/extensions/extension-marketplace#_install-an-extension).
20+
21+
### Python setup
22+
23+
While installing the extension is simple, setting up and configuring a Python environment in VSCode is a bit more involved.
24+
25+
We recommend using a dedicated *Python virtual environment* to install SQLMesh. Visit the [Python documentation](https://docs.python.org/3/library/venv.html) for more information about virtual environments.
26+
27+
We describe the steps to create and activate a virtual environment below, but additional information is available on the [SQLMesh installation page](installation.md).
28+
29+
We first install the SQLMesh library, which is required by the extension.
30+
31+
Open a terminal instance in your SQLMesh project's directory and issue this command to create a virtual environment in the `.venv` directory:
32+
33+
```bash
34+
python -m venv .venv
35+
```
36+
37+
Next, activate the virtual environment:
38+
39+
```bash
40+
source .venv/bin/activate
41+
```
42+
43+
#### Open-source SQLMesh
44+
45+
If you are using open-source SQLMesh, install SQLMesh with the `lsp` extra that enables the VSCode extension (learn more about SQLMesh extras [here](installation.md#install-extras)):
46+
47+
```bash
48+
pip install 'sqlmesh[lsp]'
49+
```
50+
51+
#### Tobiko Cloud
52+
53+
If you are using Tobiko Cloud, the `tcloud` library will install SQLMesh for you.
54+
55+
First, follow the [Python setup](#python-setup) steps above to create and activate a Python environment. Next, install `tcloud`:
56+
57+
```bash
58+
pip install tcloud
59+
```
60+
61+
Finally, add the `lsp` extra to your `tcloud.yml` configuration file, as described [here](../cloud/tcloud_getting_started.md#connect-tobiko-cloud-to-data-warehouse).
62+
63+
### VSCode Python interpreter
64+
65+
A Python virtual environment contains its own copy of Python (the "Python interpreter"). We need to make sure VSCode is using your virtual environment's interpreter rather than a system-wide or other interpreter that does not have access to the SQLMesh library we just installed.
66+
67+
Confirm that VSCode is using the correct interpreter by going to the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) and clicking `Python: Select Interpreter`. Select the Python executable that's in the virtual environment's directory `.venv`.
68+
69+
![Select interpreter](./vscode/select_interpreter.png)
70+
71+
Once that's done, validate that the everything is working correctly by checking the `sqlmesh` channel in the [output panel](https://code.visualstudio.com/docs/getstarted/userinterface#_output-panel). It displays the Python interpreter path and details of your SQLMesh installation:
72+
73+
![Output panel](./vscode/interpreter_details.png)
74+
75+
## Features
76+
77+
SQLMesh's VSCode extension makes it easy to edit and understand your SQLMesh project with these features:
78+
79+
- Lineage
80+
- Interactive view of model lineage
81+
- Editor
82+
- Auto-completion for model names and SQLMesh keywords
83+
- Model summaries when hovering over model references
84+
- Links to open model files from model references
85+
- Inline SQLMesh linter diagnostics
86+
- VSCode commands
87+
- Format SQLMesh project files
88+
- Sign in/out of Tobiko Cloud (Tobiko Cloud users only)
89+
90+
### Lineage
91+
92+
The extension adds a lineage view to SQLMesh models. To view the lineage of a model, go to the `Lineage` tab in the panel:
93+
94+
![Lineage view](./vscode/lineage.png)
95+
96+
### Editor
97+
98+
The SQLMesh VSCode extension includes several features that make editing SQLMesh models easier and quicker:
99+
100+
**Completion**
101+
102+
See auto-completion suggestions when writing SQL models, keywords, or model names.
103+
104+
![Completion](./vscode/autocomplete.png)
105+
106+
**Go to definition and hover information**
107+
108+
Hovering over a model name shows a tooltip with the model description. Clicking the model name opens the file containing the model definition.
109+
110+
**Diagnostics**
111+
112+
If you have the [SQLMesh linter](../guides/linter.md) enabled, issues are reported directly in your editor. This works for both SQLMesh's built-in linter rules and custom linter rules.
113+
114+
![Diagnostics](./vscode/diagnostics.png)
115+
116+
**Formatting**
117+
118+
SQLMesh's model formatting tool is integrated directly into the editor, so it's easy to format models consistently.
119+
120+
### Commands
121+
122+
The SQLMesh VSCode extension provides the following commands in the VSCode command palette:
123+
124+
- `Format SQLMesh project`
125+
- `Sign in to Tobiko Cloud` (Tobiko Cloud users only)
126+
- `Sign out of Tobiko Cloud` (Tobiko Cloud users only)
127+
128+
## Troubleshooting
129+
130+
### Python environment woes
131+
132+
The most common problem is the extension not using the correct Python interpreter.
133+
134+
Follow the [setup process described above](#vscode-python-interpreter) to ensure that the extension is using the correct Python interpreter.
135+
136+
If you have checked the VSCode `sqlmesh` output channel and the extension is still not using the correct Python interpreter, please raise an issue [here](https://github.com/tobikodata/sqlmesh/issues).
137+
138+
### Missing Python dependencies
139+
140+
When installing SQLMesh, some dependencies required by the VSCode extension are not installed unless you specify the `lsp` "extra".
141+
142+
If you are using open-source SQLMesh, install the `lsp` extra by running this command in your terminal:
143+
144+
```bash
145+
pip install 'sqlmesh[lsp]'
146+
```
147+
148+
If you are using Tobiko Cloud, make sure `lsp` is included in the list of extras specified in the [`tcloud.yaml` configuration file](../cloud/tcloud_getting_started.md#connect-tobiko-cloud-to-data-warehouse).
149+
150+
### SQLMesh compatibility
151+
152+
While the SQLMesh VSCode extension is in preview and the APIs to the underlying SQLMesh version are not stable, we do not guarantee compatibility between the extension and the SQLMesh version you are using.
153+
154+
If you encounter a problem, please raise an issue [here](https://github.com/tobikodata/sqlmesh/issues).
52.7 KB
Loading
84.1 KB
Loading
124 KB
Loading

docs/quickstart/vscode/lineage.png

172 KB
Loading
81.8 KB
Loading

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ nav:
3030
- guides/testing.md
3131
- guides/model_selection.md
3232
- SQLMesh tools:
33-
- guides/ui.md
33+
- quickstart/vscode.md
3434
- guides/tablediff.md
3535
- guides/linter.md
36+
- guides/ui.md
3637
- guides/observer.md
3738
- Advanced usage:
3839
- guides/customizing_sqlmesh.md

0 commit comments

Comments
 (0)