Skip to content

feat: Support direct conversion between JSONB and jaq_json::Val#102

Merged
b41sh merged 4 commits into
databendlabs:mainfrom
b41sh:feat-new-jq
Jun 15, 2026
Merged

feat: Support direct conversion between JSONB and jaq_json::Val#102
b41sh merged 4 commits into
databendlabs:mainfrom
b41sh:feat-new-jq

Conversation

@b41sh

@b41sh b41sh commented Jun 8, 2026

Copy link
Copy Markdown
Member

This PR adds direct conversion support between JSONB and jaq_json::Val, allowing jaq execution to use jaq_json::Val without going through serde_json::Value.

Main changes:

  • Added TryFrom<RawJsonb> for jaq_json::Val.
  • Added TryFrom<&jaq_json::Val> for OwnedJsonb.
  • Improved JSONB object/array builder paths to reduce unnecessary intermediate OwnedJsonb construction.
  • Optimized JSONB iterators with accurate size_hint / ExactSizeIterator.
  • Removed extra temporary allocation in ObjectIterator.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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::Val and TryFrom<&jaq_json::Val>OwnedJsonb conversions (new src/jaq.rs, exported via src/lib.rs).
  • Optimized container iteration by adding accurate size_hint() implementations and ExactSizeIterator for array/object iterators.
  • Refactored object building to avoid redundant map lookups when inserting keys (and added a build_from_entries path).

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.

Comment thread src/core/databend/builder.rs
@b41sh b41sh merged commit a163444 into databendlabs:main Jun 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants