You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
If we have a struct column that contains null then dbt show runs into an unhandled error.
Expected Behavior
We should gracefully handle this error.
Steps To Reproduce
Create 2 tables:
create or replacetabledbt_jyeo.json_error asselect struct<k json>(to_json(struct(1as a))) as v;
insert intodbt_jyeo.json_errorvalues (struct<k json>(null));
select*fromdbt_jyeo.json_error;
create or replacetabledbt_jyeo.json_okay asselect struct<k json>(to_json(struct(1as a))) as v;
insert intodbt_jyeo.json_okayvalues (struct<k json>(to_json(null)));
select*fromdbt_jyeo.json_okay;
Try to preview with dbt:
$ dbt show --inline "select * from dbt_jyeo.json_error"
22:18:25 Running with dbt=1.7.3
22:18:26 Registered adapter: bigquery=1.7.2
22:18:27 Found 0 sources, 0 exposures, 0 metrics, 447 macros, 0 groups, 0 semantic models
22:18:27
22:18:27 Concurrency: 1 threads (target='bq')
22:18:27
22:18:30 Unhandled error while executing
the JSON object must be str, bytes or bytearray, not NoneType
22:18:30 Encountered an error:
Runtime Error
the JSON object must be str, bytes or bytearray, not NoneType
$ dbt show --inline "select * from dbt_jyeo.json_okay"
22:18:54 Running with dbt=1.7.3
22:18:55 Registered adapter: bigquery=1.7.2
22:18:56 Found 0 sources, 0 exposures, 0 metrics, 447 macros, 0 groups, 0 semantic models
22:18:56
22:18:56 Concurrency: 1 threads (target='bq')
22:18:56
22:18:59 Previewing inline node:
| v || --------------- || {"k": {"a": 1}} || {"k": null} |
Try previewing in BQ:
Notice the null in italic in the first screenshot.
So it depends how the null gets into the data - if it's on the outer struct level itself (i.e. the data is literally null) vs a null that is within a json object itself (i.e. the data is a json type of which the value is null) is when we run into this error.
github-actionsbot
changed the title
[Bug] Not able preview structs when the struct is null
[ADAP-1073] [Bug] Not able preview structs when the struct is nullDec 12, 2023
Is this a new bug in dbt-bigquery?
Current Behavior
If we have a struct column that contains
null
thendbt show
runs into an unhandled error.Expected Behavior
We should gracefully handle this error.
Steps To Reproduce
So it depends how the
null
gets into the data - if it's on the outer struct level itself (i.e. the data is literallynull
) vs a null that is within a json object itself (i.e. the data is a json type of which the value isnull
) is when we run into this error.Relevant log output
No response
Environment
Additional Context
Last time we ran into something similar (#972) - it was due to the underlying bigquery python client so wont surprise me if it's more of the same.
Potential workaround for now is to check if null and coerce it into
to_json(null)
:The text was updated successfully, but these errors were encountered: