-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from danflippo/source_constraints
Merging branch that adds constraints on sources
- Loading branch information
Showing
11 changed files
with
381 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Troubleshooting dbt Constraints | ||
|
||
As it executes, dbt Constraints will log a number of messages when it cannot create a constraint. | ||
A list of the messages is provided below with additional details on how to address the message. | ||
|
||
## Messages that are displayed on the front-end of the command line interface and in the dbt log | ||
|
||
``` | ||
Skipping primary/unique key because a physical column name was not found on the table: {TABLE NAME} {TABLE COLUMNS} | ||
Skipping foreign key because a physical column was not found on the pk table: {PK TABLE NAME} {PK TABLE COLUMNS} | ||
Skipping foreign key because a physical column was not found on the fk table: {FK TABLE NAME} {FK TABLE COLUMNS} | ||
``` | ||
- These error messages typically occur when a column is misspelled or if the test uses an expression instead of a column name. | ||
- One solution can be adding the expression as an additional column in your model so that you can reference it in your constraint. | ||
|
||
|
||
``` | ||
"Skipping foreign key because a we couldn't find the child table: model={FK TABLE NAME} or source={PK TABLE NAME} | ||
``` | ||
- This is only expected to occur when a foreign key constraint is made with a source and dbt Constraints can't parse the reference to a source table. | ||
- The package is looking for something that looks like: `source("source_name", "table_name")` or `source('source_name', 'table_name')` | ||
- You may need to replace any dynamic variables with strings for the source name or table name. | ||
|
||
|
||
``` | ||
Skipping {CONSTRAINT NAME} because of insufficient privileges: {FK TABLE NAME} referencing {PK TABLE NAME} | ||
Skipping {CONSTRAINT NAME} because of insufficient privileges: {TABLE NAME} | ||
``` | ||
- You must have OWNERSHIP on the child FK table and you must have REFERENCES on the parent PK table. | ||
- For primary keys and unique keys, you need ownership on the table. | ||
- These errors most frequently apply to sources. | ||
- This can also indicate that one of your tables is actually a view | ||
|
||
|
||
``` | ||
Skipping {CONSTRAINT NAME} because a PK/UK was not found on the PK table: {PK TABLE NAME} {PK TABLE COLUMNS} | ||
``` | ||
- You either need to manually create a primary key/unique key or you need to add a test to the parent table and allow the package to create the constraint. | ||
- The package creates constraints in the order of primary keys, unique keys, foreign keys to allow parent constraints to be referenced by foreign keys. | ||
|
||
|
||
## Messages that are only displayed in the dbt log: | ||
|
||
``` | ||
Skipping {CONSTRAINT NAME} because PK/UK already exists: {TABLE NAME} {TABLE COLUMNS} | ||
Skipping {CONSTRAINT NAME} because FK already exists: {FK TABLE NAME} {FK TABLE COLUMNS} | ||
``` | ||
- Indicates duplicate constraints or that a constraint was already added to an incremental / snapshot table on a previous run | ||
- Typically not an issue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.0.4", "generated_at": "2022-04-15T00:12:22.303029Z", "invocation_id": "4e679f95-191b-4f16-a8c0-c24292e8cdb0", "env": {}}, "nodes": {}, "sources": {}, "errors": null} | ||
{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.0.4", "generated_at": "2022-04-22T21:39:49.991421Z", "invocation_id": "ce25464d-8bb3-48c4-aecd-e2013012be59", "env": {}}, "nodes": {}, "sources": {}, "errors": null} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v4.json", "dbt_version": "1.0.4", "generated_at": "2022-04-15T00:12:22.294829Z", "invocation_id": "4e679f95-191b-4f16-a8c0-c24292e8cdb0", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2022-04-15T00:12:22.259463Z", "completed_at": "2022-04-15T00:12:22.292643Z"}, {"name": "execute", "started_at": "2022-04-15T00:12:22.293042Z", "completed_at": "2022-04-15T00:12:22.293069Z"}], "thread_id": "Thread-1", "execution_time": 0.03456306457519531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "operation.dbt_constraints.dbt_constraints-on-run-end-0"}], "elapsed_time": 0.041356801986694336, "args": {"write_json": true, "use_colors": true, "printer_width": 80, "version_check": true, "partial_parse": true, "static_parser": true, "profiles_dir": "/Users/dflippo/.dbt", "send_anonymous_usage_stats": true, "event_buffer_size": 100000, "compile": true, "which": "generate", "rpc_method": "docs.generate", "indirect_selection": "eager"}} | ||
{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v4.json", "dbt_version": "1.0.4", "generated_at": "2022-04-22T21:39:49.983008Z", "invocation_id": "ce25464d-8bb3-48c4-aecd-e2013012be59", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2022-04-22T21:39:49.936114Z", "completed_at": "2022-04-22T21:39:49.980945Z"}, {"name": "execute", "started_at": "2022-04-22T21:39:49.981331Z", "completed_at": "2022-04-22T21:39:49.981355Z"}], "thread_id": "Thread-1", "execution_time": 0.04632973670959473, "adapter_response": {}, "message": null, "failures": null, "unique_id": "operation.dbt_constraints.dbt_constraints-on-run-end-0"}], "elapsed_time": 0.1201019287109375, "args": {"write_json": true, "use_colors": true, "printer_width": 80, "version_check": true, "partial_parse": true, "static_parser": true, "profiles_dir": "/Users/dflippo/.dbt", "send_anonymous_usage_stats": true, "event_buffer_size": 100000, "compile": true, "which": "generate", "rpc_method": "docs.generate", "indirect_selection": "eager"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.