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(expr): cast from jsonb to bool and number #8008

Merged
merged 2 commits into from
Feb 21, 2023
Merged

Conversation

xiangjinwu
Copy link
Contributor

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

What's changed and what's your intention?

Support casting from jsonb scalar to smallint / int / bigint / decimal / real / double precision. It is a runtime error if the jsonb type does not match.

Note that we limit the number as f64 but PostgreSQL uses arbitrary precision numeric. The f64 is enough as suggested by RFC 8259 for good interoperability. To support higher precision, we need to enable arbitrary_precision of crate serde_json and exam related code path.

There is also a subtle difference between decimal and f64 in PostgreSQL, when they round 2.5 to integer. But this issue is currently shadowed by #5576.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added an item to track fuzzing tests Sqlsmith: Sql feature generation #7934
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

Types of user-facing changes

  • SQL commands, functions, and operators

Release note

Support casting from jsonb scalar to smallint / int / bigint / decimal / real / double precision. It is a runtime error if the jsonb type does not match.

@codecov
Copy link

codecov bot commented Feb 17, 2023

Codecov Report

Merging #8008 (7099711) into main (050aa4a) will decrease coverage by 0.02%.
The diff coverage is 21.15%.

@@            Coverage Diff             @@
##             main    #8008      +/-   ##
==========================================
- Coverage   71.34%   71.32%   -0.02%     
==========================================
  Files        1129     1129              
  Lines      181502   181554      +52     
==========================================
+ Hits       129485   129498      +13     
- Misses      52017    52056      +39     
Flag Coverage Δ
rust 71.32% <21.15%> (-0.02%) ⬇️

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 21.21% <0.00%> (-2.58%) ⬇️
src/expr/src/vector_op/cast.rs 88.44% <0.00%> (-2.24%) ⬇️
src/expr/src/sig/cast.rs 83.95% <100.00%> (+2.52%) ⬆️
...frontend/src/scheduler/hummock_snapshot_manager.rs 60.00% <0.00%> (-0.48%) ⬇️
src/common/src/cache.rs 97.15% <0.00%> (-0.11%) ⬇️
src/stream/src/executor/aggregation/minput.rs 96.25% <0.00%> (-0.11%) ⬇️
src/storage/src/hummock/sstable_store.rs 64.93% <0.00%> (+0.15%) ⬆️
src/common/src/types/ordered_float.rs 31.06% <0.00%> (+0.19%) ⬆️
src/object_store/src/object/mod.rs 48.86% <0.00%> (+0.20%) ⬆️
src/meta/src/hummock/mock_hummock_meta_client.rs 65.97% <0.00%> (+0.51%) ⬆️
... and 1 more

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

@xiangjinwu xiangjinwu added the user-facing-changes Contains changes that are visible to users label Feb 20, 2023
Copy link
Member

@BugenZhao BugenZhao 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 9333ba0 into main Feb 21, 2023
@mergify mergify bot deleted the jsonb-r3-p3-cast branch February 21, 2023 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants