Home > Software design >  Display Query Text from Snowflake inside Visual Studio, apart of Error (when executing dbt)?
Display Query Text from Snowflake inside Visual Studio, apart of Error (when executing dbt)?

Time:01-28

Is it possible/how would you go about displaying the query text that gets displayed inside Snowflake UI "history" tab inside of visual studio terminal?

I current have a local dev env (docker) that I use to write dbt (https://www.getdbt.com/) locally with and I can execute on against snowflake. The syntax is different in dbt than pure sql & harder to debug until sql text is visible once executed. I have error messages, but would like to see the sql as well as it takes extra time to open up snowflake and look into the history and read the sql text that failed to complete.

Any ideas?

CodePudding user response:

Assuming that you are using Visual Studio Code for the project's development, you could supplement it with dbt Power User plugin.

Features related to generated SQL code:

CodePudding user response:

Lukasz is right, and you should use the dbt Power User plugin. It's great.

But you don't need it to view compiled SQL.

When you run dbt run or any other command, dbt first executes a compilation step, and writes your compiled models to your target directory. You can view the compiled SQL for your model in target/compiled/myproject/models/path/to/my/model.sql.

The SQL that actually gets sent to your database is a little different, since your model SQL will be wrapped in some DDL, like create table xyz as (...). You can also find that SQL in your project's target directory, target/run/myproject/models/path/to/my/model.sql.

dbt Power User is just navigating you to that file faster (which is nice!)

  • Related