Git Product home page Git Product logo

dataform-lsp-vscode's Introduction

Dataform tools - a vscode extension

Version Linux macOS Windows

⚠️ This is not an officially supported Google product.

VS Code extension for Dataform with following features

Feature Description
Dependancy graph Interative dependancy graph with external sources higlighted in distinct colors
Inline diagnostics on .sqlx file Native lsp like experience with diagnostics being directly put on both the sqlx file & compiled query
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
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
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 ]

Note

Trouble installing ? Please see FAQ section, if you are still stuck, please raise an issue here

Features

depgraph

diagnostics

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

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

formatting

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
  1. Unable to execute command e.g. error command vscode-dataform-tools.xxx not found

    • It is likely that the vscode workspace folder is not opened at the root of your dataform project. For example, if your dataform project is located at ~/Documents/repos/my_dataform_project ensure that workspace is opened at ~/Documents/repos/my_dataform_project NOT ~/Documents/repos/my_dataform_project
    • The above design is to facilitate the exection of dataform compile --json command without infering the dataform root at run time
  2. Error compiling Dataform, process existed with exit code 1

    • Check if correct dataform cli version is installed by running dataform --version in your terminal
    • Ensure that dataform cli version matches the version required by the project
    • Try compiling the project by running dataform compile on your terminal from the root of your dataform project
    • In case you need to install a specific dataform cli version by running npm i -g @dataform/[email protected]. Make sure you verify the version by running the dataform --version
    • In case the error is not due to all the above reasons it is likely that you have a compilation error in your pipeline
  3. Dataform encountered an error: Missing credentials JSON file; not found at path <your_project_path>/.df-credentials.json

    • Run dataform init-creds from the from the root of your dataform project in your terminal
    • You will be promted to pick the location and type of authentication json/adc. Choosing adc will be use your default gcp credentials that you had setup using gcloud
  4. I do not want to see compiled query each time I save it

    • Open vscode settings and search for Dataform and uncheck the following setting disable_save_on_compile
  5. I want the autocompletion to be of the format ${ref('dataset_name', 'table_name)} instead of ${ref('table_name')}

    • Open vscode settings and search for Dataform and select the prefered autocompletion format disable_save_on_compile

Known Issues

  • Features such as go to definition / dependancy graph might not work with consistantly with ${ref("dataset", "table")}
  • sync feature flickers when user tries to scroll a non-active editor. Fixes when user selects the active editor by clicking on it

TODO

  • Show pre and post operation queries in compiled query
  • Use .sqlx specific grammar. Docs on how to do it
  • 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

dataform-lsp-vscode's People

Contributors

ashish10alex avatar

Stargazers

Mike Allan Nillo avatar Taha Kiziltepe avatar Joseph Loss avatar  avatar dion edge avatar Andrew Storrs avatar

Watchers

 avatar

Forkers

wrenchchatrepo

dataform-lsp-vscode's Issues

Cannot use Dataform tools in WSL Ubuntu

Hi @ashish10alex,

I followed all of the instructions in Requirements section but still was not able to use the extension.

I got this error:
command 'vscode-dataform-tools.formatCurrentfile' not found

And here's the screenshot of runtime status of the extension:
image

Are there any steps I'm missing?
Thank you!

Compilation Timeout

Would be nice to be able to set timeout option (--timeout) in the VS Code setting. Our project size leads to compilation time > ~8 seconds, which leads to following error:
Dataform encountered an error: Compilation timed out

Compilation via CLI is working with this command:
❯ dataform compile --timeout 1min

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.