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

Patch for dbt show for a model with a struct column containing a json datatype #974

Merged
merged 7 commits into from
Oct 23, 2023

Conversation

matt-winkler
Copy link
Contributor

@matt-winkler matt-winkler commented Oct 21, 2023

resolves #972

Problem

dbt show --select currently breaks when attempted on a json field because of this bigquery python client issue

Solution

Patch as suggested by @dbeatty10

# Override broken json deserializer for dbt show --inline
def _json_from_json(value, _):
    """NOOP string -> string coercion"""
    return json.loads(value)

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

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc)

@matt-winkler matt-winkler requested a review from a team as a code owner October 21, 2023 21:48
@cla-bot cla-bot bot added the cla:yes label Oct 21, 2023
@dbeatty10 dbeatty10 added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Oct 23, 2023
@dbeatty10
Copy link
Contributor

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Oct 23, 2023

The cla-bot has been summoned, and re-checked this pull request!

@@ -0,0 +1,6 @@
kind: Fixes
body: Patch for json inline --show
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you generated a second changelog instead of updating this one, you can just delete this file

Copy link
Contributor

@mikealfare mikealfare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left one minor comment that doesn't affect functionality. I'm providing an approval so that you can merge following that update.

@dbeatty10 dbeatty10 changed the title patch for --show with json Patch for dbt show for a model with a json column Oct 23, 2023
@dbeatty10 dbeatty10 changed the title Patch for dbt show for a model with a json column Patch for dbt show for a model with a struct column containing a json datatype Oct 23, 2023
@colin-rogers-dbt colin-rogers-dbt enabled auto-merge (squash) October 23, 2023 17:34
@colin-rogers-dbt colin-rogers-dbt merged commit 6a3f458 into main Oct 23, 2023
10 checks passed
@colin-rogers-dbt colin-rogers-dbt deleted the mwinkler/json-show-patch branch October 23, 2023 17:35
@@ -0,0 +1,6 @@
kind: Fixes
body: Patch for json inline --show
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body: Patch for json inline --show
body: Patch for `dbt show` for `json` within a `struct`

github-actions bot pushed a commit that referenced this pull request Oct 23, 2023
…`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]>
(cherry picked from commit 6a3f458)
colin-rogers-dbt pushed a commit that referenced this pull request Oct 23, 2023
…`json` datatype (#974) (#976)

* 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]>
(cherry picked from commit 6a3f458)

Co-authored-by: matt-winkler <[email protected]>
github-actions bot pushed a commit that referenced this pull request Oct 24, 2023
…`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]>
(cherry picked from commit 6a3f458)
colin-rogers-dbt pushed a commit that referenced this pull request Oct 25, 2023
…`json` datatype (#974) (#978)

* 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]>
(cherry picked from commit 6a3f458)

Co-authored-by: matt-winkler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ADAP-950] [Bug] dbt show doesn't work with json structs
4 participants