-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch for
dbt show
for a model with a struct
column containing a …
…`json` datatype (#974) * patch for --show with json * update matts handle in changelog * Update dbt/adapters/bigquery/connections.py Co-authored-by: colin-rogers-dbt <[email protected]> * add json struct functional test * remove old change log * add comment to test --------- Co-authored-by: colin-rogers-dbt <[email protected]> Co-authored-by: Colin <[email protected]>
- Loading branch information
1 parent
bfc5dc4
commit 6a3f458
Showing
3 changed files
with
54 additions
and
1 deletion.
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: Fixes | ||
body: Patch for json inline --show | ||
time: 2023-10-23T08:23:12.245223-06:00 | ||
custom: | ||
Author: matt-winkler | ||
Issue: "972" |
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,9 +1,46 @@ | ||
import pytest | ||
from dbt.tests.adapter.dbt_show.test_dbt_show import BaseShowSqlHeader, BaseShowLimit | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
model_with_json_struct = """ | ||
select * | ||
from ( | ||
select | ||
struct< | ||
k array< | ||
struct<c1 int64, c2 json> | ||
> | ||
>( | ||
[ | ||
struct( | ||
1 as c1, | ||
to_json(struct(1 as a)) as c2 | ||
) | ||
] | ||
) | ||
as v | ||
) as model_limit_subq | ||
limit 5 | ||
""" | ||
|
||
|
||
class TestBigQueryShowLimit(BaseShowLimit): | ||
pass | ||
|
||
|
||
class TestBigQueryShowSqlHeader(BaseShowSqlHeader): | ||
pass | ||
|
||
|
||
# Added to check if dbt show works with JSON struct | ||
# Addresses: https://github.com/dbt-labs/dbt-bigquery/issues/972 | ||
class TestBigQueryShowSqlWorksWithJSONStruct: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"json_struct_model.sql": model_with_json_struct, | ||
} | ||
|
||
def test_sql_header(self, project): | ||
run_dbt(["show", "--select", "json_struct_model"]) |