microsoft / dbt-synapse

dbt adapter for Azure Synapse Dedicated SQL Pools
https://dbt-msft.github.io/dbt-msft-docs/docs/dbt-synapse/overview
MIT License
70 stars 34 forks source link

including database name in relation causes issue w/ SSDT #65

Open dataders opened 3 years ago

dataders commented 3 years ago

this Stack Overflow question and this dbt Slack thread brings up the issue.

to reiterate here, using the full three-part name is not an issue with an Azure Synapse Dedicated SQL pool (ASDSP). However, when trying to use SQL Server Data Tools in conjunction with ASDSP, two users report an error and asked if database name can be dropped. TBD if this would cause an issue for existing dbt-synapse users

baldwicc commented 1 year ago

+1 on disabling three-part names by default.

If a statement includes references to objects that don't exist, Synapse will respond with "USE is not supported on this platform" instead of a more developer-friendly error message telling you what object "does not exist or you don't have permission".

This hints that the query engine might be translating three-part database names into multiple USE statements, the failure of any of which triggers the error handling for USE not being a supported language element in Synapse DSP.

MS Docs ref: https://learn.microsoft.com/sql/t-sql/language-elements/use-transact-sql

The following override macros work around the issue (lifted from the SO question)

{% macro ref(model_name) %}
    {% do return(builtins.ref(model_name).include(database=false)) %}
{% endmacro %}

{% macro source(source_name, table_name) %}
    {% do return(builtins.source(source_name, table_name).include(database=false)) %}
{% endmacro %}