Skip to content

Missing dry-run support (--empty) #263

Description

Issue Summary

dbt build model_name --empty executes select * from schema.model_name where false limit 0 statements.

These aren't valid in Synapse/T-SQL and return Incorrect syntax near 'limit'. errors.

Versions

dbt-core v1.8.9
dbt-synapse v1.8.1

Cause

SynapseRelation extends BaseRelation but doesn't override the default adapter's render_limited() class method, causing the above behaviour.

@dataclass(frozen=True, eq=False, repr=False)
class SynapseRelation(BaseRelation):

Possible fix

dbt-fabric has implemented a render_limited() class method that should work for Synapse as well

    @classmethod
    # from https://github.com/microsoft/dbt-fabric/blob/525fe95c960beb3c8dc0b34130111d6284aa3eab/dbt/adapters/fabric/fabric_relation.py#L20
    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()}"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions