Skip to content

Create snapshot tables in an external location #372

Closed

Description

@stockx-dhruv

Describe the feature

A clear and concise description of what you want to happen.
In the non-snapshot models we have a config parameter location_root that we can leverage to create external tables. Issue is when we pass the parameter in snapshots it doesn't work. DBT still creates the model in the schema location.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Please include any other relevant context here.

Who will this benefit?

What kind of use case will this feature be useful for? Please be specific and provide examples, this will help us prioritize properly.

Are you interested in contributing this feature?

Let us know if you want to write some code, and how we can help.

Activity

  1. github-actions commented on Dec 19, 2023

    @github-actions

    This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue.

  2. added
    help wantedLooking for community help to implement
    and removed on Jan 8, 2025
  3. karasda commented on Dec 19, 2025

    @karasda

    We are on 1.10.14 and the location_root parameter for snapshot is working for us.
    (We are defining it in a project.yml and not in the "config" part of models)

  4. TangoEnSkai commented on Aug 23, 2026

    @TangoEnSkai
    Contributor

    Following up on @karasda's report that this works on 1.10.14 — the code path on main supports it.

    Snapshots build their table through create_table_as (materializations/snapshot.sql), which resolves to databricks__create_table_as in relations/table/create.sql, and that emits location_clause(catalog_relation) alongside the other clauses. The catalog relation gets its location from parse_model.location_root(model), which reads location_root off any node's config — it is not model-specific — and joins it with the identifier path:

    @property
    def location(self) -> Optional[str]:
        if self.location_root and self.location_path:
            return posixpath.join(self.location_root, self.location_path)

    Only the initial snapshot build goes through create_table_as; later runs merge into the existing table, so the location is set once at creation as expected.

    One gap worth noting: there is no functional test pinning this. grep -rn "location_root" tests/functional/ only turns up incremental, seed, persist_docs, and python-model cases — nothing for snapshots — so the behavior is currently unprotected against regression even though it works.

    Caveat: I verified the code path and clause construction, not an end-to-end run against a workspace with a real external location. If a maintainer can confirm, this looks closeable (optionally with a snapshot case added to the location_root coverage first).

  5. sd-db commented on Oct 24, 2026

    @sd-db
    Collaborator

    This is supported. We tested on current main (1.12.7) with location_root set both under snapshots: in dbt_project.yml and in the snapshot's own config(). In both cases the snapshot table is created as an EXTERNAL table under <location_root>/<snapshot name>, and a second dbt snapshot after a source change keeps it there and records the change. As @karasda noted, this already worked on 1.10.14. Closing as completed; please reopen with your config and dbt.log if it doesn't work for you.

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

    enhancementNew feature or requesthelp wantedLooking for community help to implement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions