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(function): Support json_path_query using JSON path #11142

Merged
merged 8 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ opendal = { version = "0.32", features = [
"services-redis",
"trust-dns",
] }
ordered-float = { version = "3.4.0", default-features = false }
jsonb = { version = "0.1.1" }
ordered-float = { version = "3.6.0", default-features = false }
jsonb = { version = "0.2.0" }

# openraft = { version = "0.8.2", features = ["compat-07"] }
# For debugging
Expand Down
13 changes: 12 additions & 1 deletion src/query/expression/src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,11 @@ impl<'a> Evaluator<'a> {
/// for each input row, along with the number of rows in each set.
pub fn run_srf(&self, expr: &Expr) -> Result<Vec<(Value<AnyType>, usize)>> {
if let Expr::FunctionCall {
span,
function,
args,
return_type,
generics,
..
} = expr
{
Expand All @@ -894,7 +896,16 @@ impl<'a> Evaluator<'a> {
.map(|expr| self.run(expr))
.collect::<Result<Vec<_>>>()?;
let cols_ref = args.iter().map(Value::as_ref).collect::<Vec<_>>();
let result = (eval)(&cols_ref, self.input_columns.num_rows());
let mut ctx = EvalContext {
generics,
num_rows: self.input_columns.num_rows(),
validity: None,
errors: None,
tz: self.func_ctx.tz,
func_ctx: self.func_ctx,
};
let result = (eval)(&cols_ref, &mut ctx);
ctx.render_error(*span, &args, &function.signature.name)?;
assert_eq!(result.len(), self.input_columns.num_rows());
return Ok(result);
}
Expand Down
7 changes: 5 additions & 2 deletions src/query/expression/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ pub enum FunctionEval {
SRF {
/// Given multiple rows, return multiple sets of results
/// for each input row, along with the number of rows in each set.
eval:
Box<dyn Fn(&[ValueRef<AnyType>], usize) -> Vec<(Value<AnyType>, usize)> + Send + Sync>,
eval: Box<
dyn Fn(&[ValueRef<AnyType>], &mut EvalContext) -> Vec<(Value<AnyType>, usize)>
+ Send
+ Sync,
>,
},
}

Expand Down
Loading