Skip to content
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

remove _json_from_json patch #1061

Merged
merged 10 commits into from
Feb 20, 2024
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20231219-153446.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: remove json patch to leverage bigquery-python improvement
time: 2023-12-19T15:34:46.843931-08:00
custom:
Author: colin-rogers-dbt
Issue: "1055"
11 changes: 0 additions & 11 deletions dbt/adapters/bigquery/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import google.auth
import google.auth.exceptions
import google.cloud.bigquery as bigquery
import google.cloud.exceptions
from google.api_core import retry, client_info
from google.auth import impersonated_credentials
Expand Down Expand Up @@ -63,16 +62,6 @@
)


# Override broken json deserializer for dbt show --inline
# can remove once this is fixed: https://github.com/googleapis/python-bigquery/issues/1500
def _json_from_json(value, _):
"""NOOP string -> string coercion"""
return json.loads(value)


bigquery._helpers._CELLDATA_FROM_JSON["JSON"] = _json_from_json


@lru_cache()
def get_bigquery_defaults(scopes=None) -> Tuple[Any, Optional[str]]:
"""
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# TODO: how to automate switching from develop to version branches?
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter

git+https://github.com/googleapis/python-bigquery.git#egg=google-cloud-bigquery
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
# if version 1.x or greater -> pin to major version
# if version 0.x -> pin to minor
black~=23.12
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/adapter/dbt_show/test_dbt_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
limit 5
"""

model_with_null_json_struct = """
select (struct<k json>(null)) as null_struct
"""


class TestBigQueryShowLimit(BaseShowLimit):
pass
Expand All @@ -40,7 +44,11 @@ class TestBigQueryShowSqlWorksWithJSONStruct:
def models(self):
return {
"json_struct_model.sql": model_with_json_struct,
"null_json_struct_model.sql": model_with_null_json_struct,
}

def test_sql_header(self, project):
run_dbt(["show", "--select", "json_struct_model"])

def test_show_with_null_json_struct(self, project):
run_dbt(["show", "--select", "null_json_struct_model"])
Loading