-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for describe column types (#796)
- Loading branch information
Showing
7 changed files
with
125 additions
and
2 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
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 |
---|---|---|
|
@@ -15,4 +15,4 @@ types-requests | |
types-mock | ||
pre-commit | ||
|
||
dbt-tests-adapter~=1.8.0 | ||
dbt-tests-adapter~=1.9.0 |
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,13 @@ | ||
base_model = """ | ||
select struct('a', 1, 'b', 'b', 'c', ARRAY(1,2,3)) as struct_col, 'hello' as str_col | ||
""" | ||
|
||
schema = """ | ||
version: 2 | ||
models: | ||
- name: base_model | ||
columns: | ||
- name: struct_col | ||
- name: str_col | ||
""" |
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,55 @@ | ||
import pytest | ||
|
||
from dbt.adapters.databricks.column import DatabricksColumn | ||
from dbt.adapters.databricks.relation import DatabricksRelation | ||
from tests.functional.adapter.columns import fixtures | ||
from dbt.tests import util | ||
|
||
|
||
class ColumnsInRelation: | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"base_model.sql": fixtures.base_model, "schema.yml": fixtures.schema} | ||
|
||
@pytest.fixture(scope="class", autouse=True) | ||
def setup(self, project): | ||
util.run_dbt(["run"]) | ||
|
||
@pytest.fixture(scope="class") | ||
def expected_columns(self): | ||
|
||
return [ | ||
DatabricksColumn( | ||
column="struct_col", | ||
dtype=( | ||
"struct<col1:string,col2:int,col3:string," | ||
"col4:string,col5:string,col6:array<int>>" | ||
), | ||
), | ||
DatabricksColumn(column="str_col", dtype="string"), | ||
] | ||
|
||
def test_columns_in_relation(self, project, expected_columns): | ||
my_relation = DatabricksRelation.create( | ||
database=project.database, | ||
schema=project.test_schema, | ||
identifier="base_model", | ||
type=DatabricksRelation.Table, | ||
) | ||
|
||
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": {}} | ||
|
||
|
||
class TestColumnsInRelationBehaviorFlagOn(ColumnsInRelation): | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return {"flags": {"column_types_from_information_schema": True}} |