-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Executing dbt run --empty
on a model with stage macro with a source relation as source_model fails. Model runs successfully if --empty
is not invocated.
Environment
dbt version: 1.8.6
automate_dv version: 0.11.0
Database/Platform: sqlserver 1.8.4
Expected behavior
The model to run.
Additional context
Issue seems to be related to
# sqlserver_relation.py
def render_limited(self) -> str:
rendered = self.render()
if self.limit is None:
return rendered
elif self.limit == 0:
return f"(select * from {rendered} where 1=0) {self._render_limited_alias()}"
else:
return f"(select TOP {self.limit} * from {rendered}) {self._render_limited_alias()}"
effectively replacing source()
to return a sub-query instead of the expected relation object and breaking subsequent logic
{# stage.sql #}
{% if source_model is mapping and source_model is not none -%}
{%- set source_name = source_model | first -%}
{%- set source_table_name = source_model[source_name] -%}
{%- set source_relation = source(source_name, source_table_name) -%}
{%- set all_source_columns = automate_dv.source_columns(source_relation=source_relation) -%}
suggested change
{# stage.sql #}
{% if source_model is mapping and source_model is not none -%}
{%- set source_name = source_model | first -%}
{%- set source_table_name = source_model[source_name] -%}
{%- set relation = source(source_name, source_table_name) -%}
{% set source_relation = api.Relation.create(database=relation.database, schema=relation.schema, identifier=relation.identifier) %}
{%- set all_source_columns = automate_dv.source_columns(source_relation=source_relation) -%}
...
WITH source_data AS (
SELECT
{{- "\n\n " ~ automate_dv.print_list(list_to_print=all_source_columns, columns_to_escape=columns_to_escape) if all_source_columns else " *" }}
FROM {{ relation }}
{%- set last_cte = "source_data" %}
)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working