vscode-dbt-power-user icon indicating copy to clipboard operation
vscode-dbt-power-user copied to clipboard

Query Preview ignoring template setting

Open andersbergren opened this issue 1 year ago • 2 comments

Expected behavior

With a configuration set in the extension setting "dbt.queryTemplate", the query preview tool should use that template instead of the default "select top 500".

Actual behavior

The query template is being ignored on any & all configuration levels (user/remote/workpace) and using the default SQL template instead, which breaks previews for t-sql queries using CTEs.

Steps To Reproduce

Running dbt within a VS Code Dev Container. I have set the query template setting to "set rowcount {limit}; {query}" on my user, in the devcontainer.json, and the .vscode/settings.json. When I run a query preview and look at the SQL tab to see the generated SQL, it will still have "select top 500".

Log output/Screenshots

No response

Operating System

Debian 11

dbt version

1.7.10

dbt Adapter

synapse 1.7.1

dbt Power User version

0.37.2

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

andersbergren avatar Apr 08 '24 21:04 andersbergren

The compiled SQL of the preview query actually doesn't match the default either. It does match the SQL generated by the dbt show command for the Synapse adapter. Perhaps this has changed, or dbt Power User has started using it for preview queries.

andersbergren avatar Apr 08 '24 22:04 andersbergren

Upstream cause: https://github.com/microsoft/dbt-synapse/pull/235

A quick local workaround is to create a macros/get_limit_subquery_sql.sql macro with the following:

{# Synapse doesnt support ANSI LIMIT clause - instead set rowcount for the session (risky) #}
{% macro get_limit_subquery_sql(sql, limit) %}
set rowcount {{ limit }};
{{ sql }}
{% endmacro %}

baldwicc avatar May 27 '24 07:05 baldwicc