Skip to content

Commit

Permalink
feat(expr): support jsonb - and #- operator (#13118)
Browse files Browse the repository at this point in the history
Signed-off-by: Runji Wang <[email protected]>
  • Loading branch information
wangrunji0408 authored Oct 30, 2023
1 parent a9d9bc9 commit c0ab3ca
Show file tree
Hide file tree
Showing 12 changed files with 444 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions proto/expr.proto
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ message ExprNode {
JSONB_EXISTS_ANY = 611;
// jsonb ?& text[]
JSONB_EXISTS_ALL = 612;
// see SUBTRACT for:
// jsonb - text -> jsonb
// jsonb - text[] -> jsonb
// jsonb - integer -> jsonb
//
// jsonb #- text[] -> jsonb
JSONB_DELETE_PATH = 615;

// Non-pure functions below (> 1000)
// ------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/common/src/types/jsonb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ impl<'a> JsonbRef<'a> {
self.0.as_null().is_some()
}

/// Returns true if this is a jsonb null, boolean, number or string.
pub fn is_scalar(&self) -> bool {
matches!(
self.0,
ValueRef::Null | ValueRef::Bool(_) | ValueRef::Number(_) | ValueRef::String(_)
)
}

/// Returns true if this is a jsonb array.
pub fn is_array(&self) -> bool {
matches!(self.0, ValueRef::Array(_))
Expand Down
Loading

0 comments on commit c0ab3ca

Please sign in to comment.