Skip to content

Commit

Permalink
update check cols all syntax to be correct (#6731)
Browse files Browse the repository at this point in the history
## What are you changing in this pull request and why?

This is a really small change to setting your `check_cols` config in the
new yaml snapshot definitions correctly. The old version was
syntactically incorrect as putting `all` in an iterable like

```
check_cols:
  - all
```
caused dbt to end up executing the [elif
block](https://github.com/dbt-labs/dbt-adapters/blob/47b19b034984e144b174b268996c20f434f7139e/dbt/include/global_project/macros/materializations/snapshots/strategies.sql#L111)
when trying to ascertain the schema shape.

The correct syntax introduced here has dbt execute the [correct
line](https://github.com/dbt-labs/dbt-adapters/blob/47b19b034984e144b174b268996c20f434f7139e/dbt/include/global_project/macros/materializations/snapshots/strategies.sql#L108)
instead.

The current syntax leads a user to get the following error as dbt tries
to execute this introspective query as it treats `all` like it's a
column name:
```
select * from (
        select all from (
                select * from database.schema.snapshot
            ) subq
    ) as __dbt_sbq
    where false
    limit 0
20:13:50 Snowflake adapter: Snowflake query id: xxx
20:13:50 Snowflake adapter: Snowflake error: xxx (xxx): xxx: SQL compilation error:
syntax error line 2 at position 19 unexpected 'from'.
20:13:50 Database Error in snapshot snapshot_name (snapshots/snapshot.yml)
  xxx (xxx): xxx: SQL compilation error:
  syntax error line 2 at position 19 unexpected 'from'.
```

## Checklist
- [ ] I have reviewed the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
- [ ] The topic I'm writing about is for specific dbt version(s) and I
have versioned it according to the [version a whole
page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
and/or [version a block of
content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content)
guidelines.
- [ ] I have added checklist item(s) to this list for anything anything
that needs to happen before this PR is merged, such as "needs technical
review" or "change base branch."
- [ ] The content in this PR requires a dbt release note, so I added one
to the [release notes
page](https://docs.getdbt.com/docs/dbt-versions/dbt-cloud-release-notes).
<!--
PRE-RELEASE VERSION OF dbt (if so, uncomment):
- [ ] Add a note to the prerelease version [Migration
Guide](https://github.com/dbt-labs/docs.getdbt.com/tree/current/website/docs/docs/dbt-versions/core-upgrade)
-->
<!-- 
ADDING OR REMOVING PAGES (if so, uncomment):
- [ ] Add/remove page in `website/sidebars.js`
- [ ] Provide a unique filename for new pages
- [ ] Add an entry for deleted pages in `website/vercel.json`
- [ ] Run link testing locally with `npm run build` to update the links
that point to deleted pages
-->

<!-- vercel-deployment-preview -->
---
🚀 Deployment available! Here are the direct links to the updated files:


-
https://docs-getdbt-com-git-trouze-check-cols-all-dbt-labs.vercel.app/reference/resource-configs/check_cols

<!-- end-vercel-deployment-preview -->
  • Loading branch information
trouze authored Jan 7, 2025
1 parent 3fc6749 commit 1b43994
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions website/docs/reference/resource-configs/check_cols.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ snapshots:
schema: snapshots
unique_key: id
strategy: check
check_cols:
- all
check_cols: all
```
</File>

Expand Down

0 comments on commit 1b43994

Please sign in to comment.