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

Fix microbatch dbt list --output JSON #11187

Conversation

internetcoffeephone
Copy link
Contributor

@internetcoffeephone internetcoffeephone commented Jan 6, 2025

Resolves #10556, #11098

Problem

Currently, running dbt list --output JSON on a project containing a microbatch model results in an error, as microbatch models require a datetime value in their config which cannot be serialized by the default JSON serializer.

Solution

There already exists a custom JSON serializer within the dbt-core project that converts datetime to ISO string format. This change uses the above serializer to resolve the error.

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 or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@internetcoffeephone internetcoffeephone requested a review from a team as a code owner January 6, 2025 17:32
Copy link

cla-bot bot commented Jan 6, 2025

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @internetcoffeephone

Copy link
Contributor

github-actions bot commented Jan 6, 2025

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@github-actions github-actions bot added the community This PR is from a community member label Jan 6, 2025
@cla-bot cla-bot bot added the cla:yes label Jan 7, 2025
@internetcoffeephone internetcoffeephone force-pushed the fix-dbt-list-microbatch-json-serialization branch 2 times, most recently from d260c24 to 704ceca Compare January 7, 2025 10:02
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.22%. Comparing base (57e279c) to head (f8b0760).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11187      +/-   ##
==========================================
- Coverage   88.92%   86.22%   -2.71%     
==========================================
  Files         187      187              
  Lines       24103    24104       +1     
==========================================
- Hits        21434    20783     -651     
- Misses       2669     3321     +652     
Flag Coverage Δ
integration 86.22% <100.00%> (-0.10%) ⬇️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 86.22% <100.00%> (-2.71%) ⬇️
Integration Tests 86.22% <100.00%> (-0.10%) ⬇️

@MichelleArk MichelleArk requested a review from QMalcolm January 9, 2025 06:19
Copy link
Contributor

@MichelleArk MichelleArk left a comment

Choose a reason for hiding this comment

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

Thank you so much for taking the time to put together this fix! Just one small comment about testing, but otherwise LGTM

Currently, running this command on a project containing a microbatch
model results in an error, as microbatch models require a datetime
value in their config which cannot be serialized by the default JSON
serializer.

There already exists a custom JSON serializer within the dbt-core
project that converts datetime to ISO string format. This change uses
the above serializer to resolve the error.
@internetcoffeephone internetcoffeephone force-pushed the fix-dbt-list-microbatch-json-serialization branch from 704ceca to f8b0760 Compare January 9, 2025 11:35
Copy link
Contributor

@QMalcolm QMalcolm left a comment

Choose a reason for hiding this comment

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

Thank you so much for doing this work ❤️

@MichelleArk MichelleArk merged commit b414ef2 into dbt-labs:main Jan 9, 2025
54 checks passed
MichelleArk pushed a commit that referenced this pull request Jan 9, 2025
Currently, running this command on a project containing a microbatch
model results in an error, as microbatch models require a datetime
value in their config which cannot be serialized by the default JSON
serializer.

There already exists a custom JSON serializer within the dbt-core
project that converts datetime to ISO string format. This change uses
the above serializer to resolve the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.9.latest cla:yes community This PR is from a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] dbt list --output json erroring with Object of type date is not JSON serializable
3 participants