Export compiled SQL and Jinja-SQL
Want to use your SQL somewhere else? We've got you covered.
Last updated
Want to use your SQL somewhere else? We've got you covered.
Last updated
To export the full SQL (including all parent cells) for a particular cell, right-click on the cell and select the Copy as -> Copy as SQL option (or the Export SQL button in the design bar).
Exporting SQL requires a canvas analyst role.
A new panel will open showing:
A preview of the compiled SQL for this cell
An overview of all of the upstream cells that have been compiled into this export
Selecting this option makes it possible to customise the number of upstream cells included in the exported SQL by selectively treating cells as dbt models. Use this option to generate code that is compatible with dbt.
Clicking on a cell in the DAG summary will convert it to a model (indicated by the dbt symbol), which means that all cells further upstream need not be included in the compiled code. Any references to models are also converted to ref()
invocations.
Depending on the contents of your cells, other changes may be applied to the compiled code (especially if those cells contain more complex Jinja expressions). A summary of those changes is visible by clicking on View code changes.