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

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

Open
baldwicc opened this issue Dec 17, 2024 · 1 comment
Open

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

baldwicc opened this issue Dec 17, 2024 · 1 comment

Comments

@baldwicc
Copy link
Contributor

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()}"
@alittlesliceoftom
Copy link

Hey @baldwicc , verified and repeated this behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants