Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Preview ignoring template setting #1053

Open
1 task
andersbergren opened this issue Apr 8, 2024 · 2 comments
Open
1 task

Query Preview ignoring template setting #1053

andersbergren opened this issue Apr 8, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@andersbergren
Copy link

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 andersbergren added the bug Something isn't working label Apr 8, 2024
@andersbergren
Copy link
Author

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.

@baldwicc
Copy link

baldwicc commented May 27, 2024

Upstream cause: microsoft/dbt-synapse#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 %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants