-
Notifications
You must be signed in to change notification settings - Fork 59
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
Use redshift_connector
's get_columns
call to get column metadata
#899
Merged
Merged
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f410771
changelog
mikealfare 85f89d5
point to dev branches for behavior flag functionality
mikealfare d316b28
point to dev branches
mikealfare 01b3fbc
register behavior flag
mikealfare 5b3e5d9
register behavior flag
mikealfare c1704bf
add call to redshift get_columns behind a behavior flag
mikealfare 5f91dcc
add tests showing different behavior when the flag is turned off and on
mikealfare 2ccd60f
update logging event
mikealfare f813295
update method name to the new name in BaseAdapter
mikealfare fad7e35
point dbt-common back to main
mikealfare 5598258
point dbt-core back to main
mikealfare babb577
point dbt-adapters back to main
mikealfare e2c2579
add boundary test to better understand get_columns method
mikealfare 4b42451
Merge branch 'main' into remove-pg-catalog
mikealfare 5689efc
update flag name
mikealfare 142feed
update flag name in the test
mikealfare 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Remove `pg_catalog` from metadata queries | ||
time: 2024-08-26T12:39:54.481505-04:00 | ||
custom: | ||
Author: mikealfare | ||
Issue: "555" |
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,59 @@ | ||
from dbt.adapters.base import Column | ||
from dbt.tests.util import run_dbt | ||
import pytest | ||
|
||
from dbt.adapters.redshift import RedshiftRelation | ||
|
||
|
||
class ColumnsInRelation: | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"my_model.sql": "select 1.23 as my_num, 'a' as my_char"} | ||
|
||
@pytest.fixture(scope="class", autouse=True) | ||
def setup(self, project): | ||
run_dbt(["run"]) | ||
|
||
@pytest.fixture(scope="class") | ||
def expected_columns(self): | ||
return [] | ||
|
||
def test_columns_in_relation(self, project, expected_columns): | ||
my_relation = RedshiftRelation.create( | ||
database=project.database, | ||
schema=project.test_schema, | ||
identifier="my_model", | ||
type=RedshiftRelation.View, | ||
) | ||
with project.adapter.connection_named("_test"): | ||
actual_columns = project.adapter.get_columns_in_relation(my_relation) | ||
assert actual_columns == expected_columns | ||
|
||
|
||
class TestColumnsInRelationBehaviorFlagOff(ColumnsInRelation): | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return {"flags": {}} | ||
|
||
@pytest.fixture(scope="class") | ||
def expected_columns(self): | ||
# the SDK query returns "varchar" whereas our custom query returns "character varying" | ||
return [ | ||
Column(column="my_num", dtype="numeric", numeric_precision=3, numeric_scale=2), | ||
Column(column="my_char", dtype="character varying", char_size=1), | ||
] | ||
|
||
|
||
class TestColumnsInRelationBehaviorFlagOn(ColumnsInRelation): | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return {"flags": {"retire_pg_catalog": True}} | ||
|
||
@pytest.fixture(scope="class") | ||
def expected_columns(self): | ||
# the SDK query returns "varchar" whereas our custom query returns "character varying" | ||
return [ | ||
Column(column="my_num", dtype="numeric", numeric_precision=3, numeric_scale=2), | ||
Column(column="my_char", dtype="varchar", char_size=1), | ||
] |
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.
Make sure this name aligns with the naming convention: https://github.com/dbt-labs/dbt-core/blob/main/docs/guides/behavior-change-flags.md#rules-for-introducing-a-new-flag