feat: Support direct conversion between JSONB and jaq_json::Val#102
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces first-class interop between this crate’s JSONB representation and jaq_json::Val, enabling jaq execution to operate on jaq_json::Val directly (without a serde_json::Value hop). It also includes targeted performance/ergonomics improvements in JSONB builders and iterators to better support the new conversion paths.
Changes:
- Added
TryFrom<RawJsonb>→jaq_json::ValandTryFrom<&jaq_json::Val>→OwnedJsonbconversions (newsrc/jaq.rs, exported viasrc/lib.rs). - Optimized container iteration by adding accurate
size_hint()implementations andExactSizeIteratorfor array/object iterators. - Refactored object building to avoid redundant map lookups when inserting keys (and added a
build_from_entriespath).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/it/functions.rs | Small iterator usage cleanup in scalar key/value extraction tests. |
| src/raw.rs | Minor simplification of RawJsonb::len(). |
| src/lib.rs | Exposes the new jaq module publicly. |
| src/jaq.rs | Implements JSONB ↔ jaq_json::Val conversions and adds focused unit tests for numeric edge cases. |
| src/core/databend/ser.rs | Removes unnecessary into_iter() when zipping values during object serialization. |
| src/core/databend/iterator.rs | Adds new_with_len, exact size_hint(), and ExactSizeIterator for JSONB iterators; refactors object iteration to remove temporary allocations. |
| src/core/databend/builder.rs | Refactors object builder insertion and adds build_from_entries; object build path refactoring impacts allocations. |
| Cargo.toml | Adds the jaq-json dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sundy-li
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds direct conversion support between
JSONBandjaq_json::Val, allowing jaq execution to usejaq_json::Valwithout going throughserde_json::Value.Main changes:
TryFrom<RawJsonb>forjaq_json::Val.TryFrom<&jaq_json::Val>forOwnedJsonb.JSONBobject/array builder paths to reduce unnecessary intermediateOwnedJsonbconstruction.JSONBiterators with accuratesize_hint/ExactSizeIterator.ObjectIterator.