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: jsonb || operator #12502

Merged
merged 17 commits into from
Oct 3, 2023
Merged

feat: jsonb || operator #12502

merged 17 commits into from
Oct 3, 2023

Conversation

taytzehao
Copy link
Contributor

@taytzehao taytzehao commented Sep 23, 2023

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

What's changed and what's your intention?

fix #12180 This PR adds the jsonb concatenation operator. The concatenation takes into consideration 4 situations ie

  1. both inputs are objects, the return type would be jsonb object
  2. both/either inputs are array, the return type would be a jsonb array
  3. for other situations, both inputs would be placed into an array4.
    The limitation of this PR is that it only concatenates when both data type are jsonb. If either data type is not jsonb, a binding error would still be present.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Laptop space is running low to run it locally, any tips to run it with minimal space?).
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

RELEASE NOTE:
Added operator that allow jsonb data types to be concatenated. Documentation PR is here.

@taytzehao taytzehao marked this pull request as ready for review September 24, 2023 07:21
Copy link
Contributor

@xiangjinwu xiangjinwu 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 for the contribution!

proto/expr.proto Outdated Show resolved Hide resolved
src/frontend/src/binder/expr/function.rs Outdated Show resolved Hide resolved
src/frontend/src/binder/expr/binary_op.rs Outdated Show resolved Hide resolved
@@ -210,6 +210,12 @@ impl From<Value> for JsonbVal {
}
}

impl<'a> From<&'a Value> for JsonbRef<'a> {
Copy link
Contributor

@xiangjinwu xiangjinwu Sep 25, 2023

Choose a reason for hiding this comment

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

It is an anti-pattern to

  • take serde_json::Value out of JsonbRef
  • process serde_json::Value
  • put processed serde_json::Value back into a JsonbVal

because we may switch away from serde_json #11805. This pattern is a leak of implementation detail.

However, avoiding this means moving the concat implementation to common crate, which could hurt build time #12485

cc @wangrunji0408 @xxchan It's up to you how we proceed with the code organization.

Copy link
Member

Choose a reason for hiding this comment

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

Since the complexity is not very high, I feel comfortable to proceed in whatever way. 🤣

@xxchan xxchan enabled auto-merge October 3, 2023 12:48
@xxchan xxchan added this pull request to the merge queue Oct 3, 2023
Merged via the queue into risingwavelabs:main with commit 8db10db Oct 3, 2023
9 of 10 checks 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.

concat jsonb || jsonbjsonb
3 participants