Skip to content

ashish10alex/vscode-dataform-tools

Repository files navigation

Dataform tools - a vscode extension

Version Linux macOS

⚠️ This is not an officially supported Google product.

Dataform vscode extension which supports

Feature Description
Auto-completion - declarations in ${ref("..")} trigger when $ character is typed

- Dependencies when " or ' is typed inside the config block which has dependencies keyword is in the line prefix

- tags when " or ' is typed inside the config block which has tags keyword is in the line prefix
Go to definition Go to definition for source in $ref{("MY_SOURCE")}. Takes you to MY_SOURCE.sqlx or sources.js at the line where MY_SOURCE is defined
Inline diagnostics on .sqlx file Native lsp like experience with diagnostics being directly put on both the sqlx file & compiled query
Code actions Apply dry run suggestions at the speed of thought
Compilation & Dry run stats - Live compiled query in a vertical split on save which is in sync with the current cursor position of your .sqlx file

- Data processed by query on bottom right on successful dry run
Run a specific file/tag Run a file/tag, optionally with dependencies/dependents with vscode command pallet / menu icons
Format using Sqlfluff 🪄 Fromat .sqlx files based on sqlfluff config using formatdataform cli

Requirements

  1. Dataform cli

    npm i -g @dataform/cli

  2. Setup default application credentials for GCP

  3. To enable formatting using sqlfluff config install formatdataform extension [ optional ]

    # install python and run
    pip install sqlfluff
    
    # install formatdataform cli
    curl -sSfL https://raw.githubusercontent.com/ashish10alex/formatdataform/main/install_latest.sh | bash

    You can verify if formatdataform is installed correctly by running

    formatdataform --help
  4. To enable prettier diagnostics install Error Lens extension [ optional ]

Features

Auto completion support for dependencies when " or ' is typed inside the config block which has dependencies keyword is in the line prefix auto-completion

  • declarations in ${ref("..")} trigger when $ character is typed auto-completion

  • Auto completion support for tags when " or ' is typed inside the config block which has tags keyword is in the line prefix auto-completion

Go to definition for source in $ref{("MY_SOURCE")}. Takes you to MY_SOURCE.sqlx or sources.js at the line where MY_SOURCE is defined go-to-definition

diagnostics

  • Live compiled query in a vertical split on save which is in sync with the current cursor position of your sqlx file. Data processed by query on bottom right on successful dry run compilation

Open vscode command pallet by pressing CTLR + SHIFT + p or CMD + SHIFT + p on mac and run one of the required commands

Commands
Dataform: Run current file
Dataform: Run current file with dependencies
Dataform: Run current file with dependents
Dataform: Run current tag
Dataform: Run current tag with dependencies
Dataform: Run current tag with dependents
Dataform: Format current file

Extension Settings

Known Issues

  • sync feature flickers when user tries to scroll a non-active editor. Fixes when user selects the active editor by clicking on it

TODO

  • Preview query results
  • Bundle javascript files in the extension using esbuild or webpack
  • Handle case where user is not connected to internet or on vpn where network request for dry run cannot be made
  • Add proper logging, winston-transport-vscode