-
Notifications
You must be signed in to change notification settings - Fork 28
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
Pass down schema on table creation #271
Open
simonpannek
wants to merge
10
commits into
dremio:main
Choose a base branch
from
simonpannek:apply-schema-to-tables
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
442df41
Adjust schema name generation
simonpannek 69fa2f5
Add test cases
simonpannek 3195fd1
Minor changes
simonpannek a5de7f8
Add additional test cases (currently failing)
simonpannek 6d03064
Create space on folder creation
simonpannek 4777f1a
Start using root_path for tables
simonpannek a405791
Minor changes
simonpannek 2e8bf4a
Delete app.code-workspace
simonpannek 367964a
Fix twin strategy
simonpannek 7d391e4
Remove logging
simonpannek 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
117 changes: 117 additions & 0 deletions
117
tests/functional/adapter/dremio_specific/test_nested_schema.py
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,117 @@ | ||
import pytest | ||
from dbt.tests.util import run_dbt, get_connection | ||
from tests.utils.util import relation_from_name | ||
|
||
|
||
custom_schema_table_no_schema_model = """ | ||
{{ config( | ||
materialized='table' | ||
) }} | ||
select 1 as id | ||
""" | ||
|
||
custom_schema_table_model = """ | ||
{{ config( | ||
materialized='table', | ||
schema='schema' | ||
) }} | ||
select 1 as id | ||
""" | ||
|
||
custom_schema_table_nested_model = """ | ||
{{ config( | ||
materialized='table', | ||
schema='nested.schema' | ||
) }} | ||
select 1 as id | ||
""" | ||
|
||
custom_schema_view_no_schema_model = """ | ||
{{ config( | ||
materialized='view' | ||
) }} | ||
select 1 as id | ||
""" | ||
|
||
custom_schema_view_model = """ | ||
{{ config( | ||
materialized='view', | ||
schema='schema' | ||
) }} | ||
select 1 as id | ||
""" | ||
|
||
custom_schema_view_nested_model = """ | ||
{{ config( | ||
materialized='view', | ||
schema='nested.schema' | ||
) }} | ||
select 1 as id | ||
""" | ||
|
||
|
||
class TestGetCustomSchema: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"custom_schema_table_no_schema.sql": custom_schema_table_no_schema_model, | ||
"custom_schema_table.sql": custom_schema_table_model, | ||
"custom_schema_table_nested.sql": custom_schema_table_nested_model, | ||
"custom_schema_view_no_schema.sql": custom_schema_view_no_schema_model, | ||
"custom_schema_view.sql": custom_schema_view_model, | ||
"custom_schema_view_nested.sql": custom_schema_view_nested_model, | ||
} | ||
|
||
def test_custom_schema_table_no_schema(self, project): | ||
run_dbt(["run", "--select", "custom_schema_table_no_schema"]) | ||
table_relation = relation_from_name( | ||
project.adapter, "custom_schema_table_no_schema") | ||
with get_connection(project.adapter): | ||
columns = project.adapter.get_columns_in_relation(table_relation) | ||
assert len(columns) == 1 | ||
assert columns[0].name == "id" | ||
|
||
def test_custom_schema_table(self, project): | ||
run_dbt(["run", "--select", "custom_schema_table"]) | ||
table_relation = relation_from_name( | ||
project.adapter, "schema.custom_schema_table") | ||
with get_connection(project.adapter): | ||
columns = project.adapter.get_columns_in_relation(table_relation) | ||
assert len(columns) == 1 | ||
assert columns[0].name == "id" | ||
|
||
def test_custom_schema_table_nested(self, project): | ||
run_dbt(["run", "--select", "custom_schema_table_nested"]) | ||
table_relation = relation_from_name( | ||
project.adapter, "nested.schema.custom_schema_table_nested") | ||
with get_connection(project.adapter): | ||
columns = project.adapter.get_columns_in_relation(table_relation) | ||
assert len(columns) == 1 | ||
assert columns[0].name == "id" | ||
|
||
def test_custom_schema_view_no_schema(self, project): | ||
run_dbt(["run", "--select", "custom_schema_view_no_schema"]) | ||
view_relation = relation_from_name( | ||
project.adapter, "custom_schema_view_no_schema") | ||
with get_connection(project.adapter): | ||
columns = project.adapter.get_columns_in_relation(view_relation) | ||
assert len(columns) == 1 | ||
assert columns[0].name == "id" | ||
|
||
def test_custom_schema_view(self, project): | ||
run_dbt(["run", "--select", "custom_schema_view"]) | ||
view_relation = relation_from_name( | ||
project.adapter, "schema.custom_schema_view") | ||
with get_connection(project.adapter): | ||
columns = project.adapter.get_columns_in_relation(view_relation) | ||
assert len(columns) == 1 | ||
assert columns[0].name == "id" | ||
|
||
def test_custom_schema_view_nested(self, project): | ||
run_dbt(["run", "--select", "custom_schema_view_nested"]) | ||
view_relation = relation_from_name( | ||
project.adapter, "nested.schema.custom_schema_view_nested") | ||
with get_connection(project.adapter): | ||
columns = project.adapter.get_columns_in_relation(view_relation) | ||
assert len(columns) == 1 | ||
assert columns[0].name == "id" |
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.
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.
What if there is no 1st element? and only zero one?