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

feat(common): introduce JsonbVal as Scalar and JsonbRef as ScalarRef #7977

Merged
merged 3 commits into from
Feb 16, 2023

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Feb 16, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Part of the jsonb type support (preview all on this branch):

serde_json is chosen instead of simd_json for the following reasons:

  • Better interoperability with other libraries (e.g. postgres_types).
  • Despite the name BorrowedValue, it is not Copy and not suitable for JsonbRef.
  • simd_json uses HashMap but serde_json defaults to BTreeMap, which has a deterministic ordering and string representation.

Checklist

  • I have written necessary rustdoc comments
    - [ ] I have added necessary unit tests and integration tests (tested together in later part)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR DOES NOT contain user-facing changes (yet).

@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #7977 (9883f32) into main (d074398) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #7977      +/-   ##
==========================================
- Coverage   71.45%   71.42%   -0.04%     
==========================================
  Files        1118     1119       +1     
  Lines      180316   180399      +83     
==========================================
- Hits       128849   128845       -4     
- Misses      51467    51554      +87     
Flag Coverage Δ
rust 71.42% <0.00%> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
src/common/src/array/jsonb_array.rs 0.00% <0.00%> (ø)
src/common/src/array/mod.rs 73.79% <ø> (ø)
src/common/src/types/mod.rs 73.46% <0.00%> (-0.16%) ⬇️
src/common/src/types/to_binary.rs 38.29% <0.00%> (-0.84%) ⬇️
src/common/src/util/value_encoding/mod.rs 86.30% <0.00%> (-0.52%) ⬇️
src/object_store/src/object/mem.rs 86.87% <0.00%> (-0.39%) ⬇️
src/storage/src/hummock/sstable_store.rs 65.00% <0.00%> (-0.32%) ⬇️
src/storage/src/hummock/compactor/iterator.rs 97.95% <0.00%> (-0.30%) ⬇️
src/common/src/cache.rs 97.15% <0.00%> (-0.11%) ⬇️
src/storage/src/hummock/compactor/mod.rs 80.88% <0.00%> (+0.19%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@TennyZhuang TennyZhuang left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot merged commit 7dde331 into main Feb 16, 2023
@mergify mergify bot deleted the jsonb-r3-p0-scalar branch February 16, 2023 13:38
mergify bot pushed a commit that referenced this pull request Feb 17, 2023
Part of the `jsonb` type support (preview all on [this branch](https://github.com/risingwavelabs/risingwave/compare/XJ-jsonb-WIP-2?expand=1)):
* #7977
* Introduce `ArrayBuilder` and `Array` **(this PR)**
* Introduce `DataType::Jsonb`
* Add more expressions #7714

In this PR:
* The in-memory layout of `JsonbArray` is simply a `Vec` or roots of json trees. This is easier to operate but do have space for optimization.
* The protobuf layout is the same as `bytea` variable length array, with each element storing its value encoding. In case we switch to a newer protobuf layout, a new ArrayType enum value can be introduced without affecting parts other than `to_protobuf` and `from_protobuf`.
* Refactored `VarSizedValueReader` from returning `RefItem` into accepting `&mut ArrayBuilder`. This is to use `JsonbArrayBuilder::append_move` on the deserialized `OwnedItem`. It is impossible to get a `JsonbArray::RefItem` from `&[u8]`.
* Blanket implementation for `arrow` / `HashKeySerDe` / `RandValue`.

Approved-By: BugenZhao
mergify bot pushed a commit that referenced this pull request Feb 17, 2023
Part of the `jsonb` type support:
* #7977
* #7986
* Introduce `DataType::Jsonb` **(this PR)**
* Add more expressions #7714

In this PR:
* Add `DataType::Jsonb`.
* Support constructing it from string and displaying it as string.
* Add e2e tests for `insert` and `select`.

Also tested for the following but not added in CI:
* prepared statement with BINARY format
* kafka+json source with a `jsonb` field

Approved-By: BugenZhao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants