-
Notifications
You must be signed in to change notification settings - Fork 20
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
[Bug] TypeError: Object of type Table is not JSON serializable #199
Comments
Thanks for reaching out @K-Oxon ! 🤩 First, did you happen to try out the from dbt_common.utils.encoding import ForgivingJSONEncoder
# ...
print(json.dumps(asdict(res), cls=ForgivingJSONEncoder)) Second, it sounds like you're proposing that we update the code here if isinstance(obj, agate.Table):
return None It sounds like you're proposing that we update the following code? dbt-common/dbt_common/utils/encoding.py Lines 26 to 48 in 60ffb06
And just add this additional conditional in there somewhere? (el)if isinstance(obj, agate.Table):
return None If so, did you try it out and see if it worked in your scenario? |
@dbeatty10
from dbt_common.utils.encoding import ForgivingJSONEncoder
# ...
print(json.dumps(asdict(res), cls=ForgivingJSONEncoder)) The output is:
I implemented the following class CustomJSONEncoder(JSONEncoder):
def default(self, obj):
if isinstance(obj, agate.Table):
return None
return super().default(obj) |
Awesome @K-Oxon very glad I'm going to close this as not a bug since |
Is this a new bug in dbt-common?
Current Behavior
When I try to parse the return value
dbtRunnerResult
of adbt seed
command withJSONEncoder
, I get the following error:TypeError: Object of type Table is not JSON serializable
Expected Behavior
The JSONEncoder can handle
agate.Table
objects without raising an error.Steps To Reproduce
Relevant log output
Additional Context
I think we can solve this problem by adding the following to the default method:
Reference:
https://github.com/dbt-labs/dbt-core/blob/5d32aa8b62af4f664db2801ebd1ecd7efc730eb3/core/dbt/artifacts/schemas/run/v5/run.py#L37
The text was updated successfully, but these errors were encountered: