-
Notifications
You must be signed in to change notification settings - Fork 238
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
Fix persist_docs for columns #180
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,3 @@ | ||
id,name | ||
1,Alice | ||
2,Bob |
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,26 @@ | ||
version: 2 | ||
|
||
seeds: | ||
- name: seed | ||
description: | | ||
Seed model description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
columns: | ||
- name: id | ||
description: | | ||
id Column description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
- name: name | ||
description: | | ||
Some stuff here and then a call to | ||
{{ doc('my_fun_doc')}} |
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,10 @@ | ||
{% docs my_fun_doc %} | ||
name Column description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
|
||
{% enddocs %} |
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 @@ | ||
select 1 as id, 'Alice' as name |
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,71 @@ | ||
version: 2 | ||
|
||
models: | ||
|
||
- name: table_parquet_model | ||
description: | | ||
Table model description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
columns: | ||
- name: id | ||
description: | | ||
id Column description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
- name: name | ||
description: | | ||
Some stuff here and then a call to | ||
{{ doc('my_fun_doc')}} | ||
|
||
- name: table_delta_model | ||
description: | | ||
Table model description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
columns: | ||
- name: id | ||
description: | | ||
id Column description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
- name: name | ||
description: | | ||
Some stuff here and then a call to | ||
{{ doc('my_fun_doc')}} | ||
|
||
- name: view_model | ||
description: | | ||
View model description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting | ||
columns: | ||
- name: id | ||
description: | | ||
id Column description "with double quotes" | ||
and with 'single quotes' as welll as other; | ||
'''abc123''' | ||
reserved -- characters | ||
-- | ||
/* comment */ | ||
Some $lbl$ labeled $lbl$ and $$ unlabeled $$ dollar-quoting |
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,2 @@ | ||
{{ config(materialized='table', file_format='delta') }} | ||
select 1 as id, 'Joe' as name |
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,2 @@ | ||
{{ config(materialized='table', file_format='parquet') }} | ||
select 1 as id, 'Joe' as name |
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,2 @@ | ||
{{ config(materialized='view') }} | ||
select 2 as id, 'Bob' as name |
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,72 @@ | ||
from cProfile import run | ||
from test.custom.base import DBTSparkIntegrationTest, use_profile | ||
import dbt.exceptions | ||
|
||
import json | ||
|
||
|
||
class TestPersistDocsDelta(DBTSparkIntegrationTest): | ||
@property | ||
def schema(self): | ||
return "persist_docs_columns" | ||
|
||
@property | ||
def models(self): | ||
return "models" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
'config-version': 2, | ||
'models': { | ||
'test': { | ||
'+persist_docs': { | ||
"relation": True, | ||
"columns": True, | ||
}, | ||
} | ||
}, | ||
'seeds': { | ||
'test': { | ||
'+persist_docs': { | ||
"relation": True, | ||
"columns": True, | ||
}, | ||
'+file_format': 'delta', | ||
'+quote_columns': True | ||
} | ||
}, | ||
} | ||
|
||
def test_delta_comments(self): | ||
self.run_dbt(['seed']) | ||
self.run_dbt(['run']) | ||
|
||
for table in ['table_parquet_model', 'table_delta_model', 'seed']: | ||
results = self.run_sql( | ||
'describe extended {schema}.{table}'.format(schema=self.unique_schema(), table=table), | ||
fetch='all' | ||
) | ||
|
||
for result in results: | ||
# parquet model will have table-level comment only | ||
if result[0] == 'Comment': | ||
whatis = 'Seed' if table == 'seed' else 'Table' | ||
assert result[1].startswith(f'{whatis} model description') | ||
|
||
# delta tables will have table-level and column-level comments | ||
if table in ['table_delta_model', 'seed']: | ||
if result[0] == 'id': | ||
assert result[2].startswith('id Column description') | ||
if result[0] == 'name': | ||
assert result[2].startswith('Some stuff here and then a call to') | ||
|
||
# runs on Spark v3.0 | ||
@use_profile("databricks_cluster") | ||
def test_delta_comments_databricks_cluster(self): | ||
self.test_delta_comments() | ||
|
||
# runs on Spark v3.0 | ||
@use_profile("databricks_sql_endpoint") | ||
def test_delta_comments_databricks_sql_endpoint(self): | ||
self.test_delta_comments() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do the
run_hooks
calls change? Is it related to thepersist_docs
change or is this related to something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really related to the specific change in the PR at all, I just noticed because I was editing related lines. We clearly copied these lines from the default
seed
materialization a few years back. The default materialization, which was originally written for Redshift/Postgres, assumes a transactional database. Some hooks may want to run before the main transaction starts (begin
), after it starts, before it ends (commit
), or after it ends.Spark doesn't have transactions, so there's no need to distinguish between
inside_transaction = True|False
. I figured I would simplify it while here, but I'd also be fine reverting those lines for PR cleanliness.