dataform-co / dataform

Dataform is a framework for managing SQL based data operations in BigQuery
https://cloud.google.com/dataform/docs
Apache License 2.0
834 stars 161 forks source link

Feature request - see compiled SQL in VSCODE/CLI #1393

Open teraearlywine opened 1 year ago

teraearlywine commented 1 year ago

Am developing in vscode using the CLI, and one of the best features of the web app is being able to copy the compiled SQL -> edit/prototype using bq console or the draft-queries part.

Would like to be able to see what the compiled SQL of the table I'm working on in vscode too. So far haven't been able to figure out how to do this yet if it's already available

andres-lowrie commented 5 months ago

not sure how to do this in vscode , but via the cli you can do the following assuming you have jq (this is how I get the compiled sql)

cd location/where/your/dataform.json/file/is

npx dataform run --dry-run --json --actions $name-of-action | jq -r '.actions[0].tasks[0].statement'

if you have bat you can get pretty output as well

npx dataform run --dry-run --json --actions $name-of-action | jq -r '.actions[0].tasks[0].statement' | bat --language=sql