-
Notifications
You must be signed in to change notification settings - Fork 590
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
fix(udf): allow aggregate:
prefixed sql udf
#18203
Conversation
aggregate:
prefixed scalar functionaggregate:
prefixed sql udf
0ee1e49
to
41a1a96
Compare
bbf3bdf
to
20a7dc5
Compare
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
20a7dc5
to
2c3c0e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM
let mut udf_context = HashMap::new(); | ||
for (c, e) in context { | ||
// Note that we need to bind the args before actual delve in the function body | ||
// This will update the context in the subsequent inner calling function | ||
// e.g., | ||
// - create function print(INT) returns int language sql as 'select $1'; | ||
// - create function print_add_one(INT) returns int language sql as 'select print($1 + 1)'; | ||
// - select print_add_one(1); # The result should be 2 instead of 1. | ||
// Without the pre-binding here, the ($1 + 1) will not be correctly populated, | ||
// causing the result to always be 1. | ||
let Ok(e) = self.bind_expr(e) else { | ||
return Err(ErrorCode::BindError( | ||
"failed to bind the argument, please recheck the syntax".to_string(), | ||
) | ||
.into()); | ||
}; | ||
udf_context.insert(c, e); | ||
for (i, arg) in args.into_iter().enumerate() { | ||
if func.arg_names[i].is_empty() { | ||
udf_context.insert(format!("${}", i + 1), arg); | ||
} else { | ||
// The index mapping here is accurate | ||
// So that we could directly use the index | ||
udf_context.insert(func.arg_names[i].clone(), arg); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I don't quite get how this context works. Could you please elaborate it more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context contains a mapping of argument name -> argument expression
. If an argument has no name, $n
will be used as its name. I just updated the comment to make it more clear.
Signed-off-by: Richard Chien <[email protected]>
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Fixes #18202.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
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.