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): add json path functions #13568

Merged
merged 14 commits into from
Dec 5, 2023
Merged
17 changes: 15 additions & 2 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions proto/expr.proto
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ message ExprNode {
TO_JSONB = 617;
JSONB_BUILD_ARRAY = 618;
JSONB_BUILD_OBJECT = 619;
JSONB_PATH_EXISTS = 620;
JSONB_PATH_MATCH = 621;
JSONB_PATH_QUERY_ARRAY = 622;
JSONB_PATH_QUERY_FIRST = 623;

// Non-pure functions below (> 1000)
// ------------------------
Expand Down Expand Up @@ -295,6 +299,7 @@ message TableFunction {
JSONB_EACH = 12;
JSONB_EACH_TEXT = 13;
JSONB_OBJECT_KEYS = 14;
JSONB_PATH_QUERY = 15;
// User defined table function
UDTF = 100;
}
Expand Down
11 changes: 8 additions & 3 deletions src/common/src/types/jsonb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,14 @@ impl<'a> JsonbRef<'a> {
buf
}

/// Returns a jsonb `null` value.
pub fn null() -> Self {
Self(ValueRef::Null)
}

/// Returns true if this is a jsonb `null`.
pub fn is_jsonb_null(&self) -> bool {
self.0.as_null().is_some()
self.0.is_null()
}

/// Returns true if this is a jsonb null, boolean, number or string.
Expand All @@ -250,12 +255,12 @@ impl<'a> JsonbRef<'a> {

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

/// Returns true if this is a jsonb object.
pub fn is_object(&self) -> bool {
matches!(self.0, ValueRef::Object(_))
self.0.is_object()
}

/// Returns the type name of this jsonb.
Expand Down
4 changes: 4 additions & 0 deletions src/expr/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha1 = "0.10"
sha2 = "0.10"
sql-json-path = { git = "https://github.com/risingwavelabs/sql-json-path.git", rev = "95a06aa", features = [
"jsonbb",
] }
thiserror = "1"
tokio = { version = "0.2", package = "madsim-tokio", features = ["time"] }
tracing = "0.1"
# sql-json-path = { path = "../../../../sql-json-path", features = ["jsonbb"] }
wangrunji0408 marked this conversation as resolved.
Show resolved Hide resolved

[target.'cfg(not(madsim))'.dependencies]
workspace-hack = { path = "../../workspace-hack" }
Expand Down
Loading
Loading