r1b commented on code in PR #18450:
URL: https://github.com/apache/datafusion/pull/18450#discussion_r2496555706
##########
datafusion/sql/src/expr/value.rs:
##########
@@ -123,8 +123,19 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
return if param_data_types.is_empty() {
Ok(Expr::Placeholder(Placeholder::new_with_field(param,
None)))
} else {
- // when PREPARE Statement, param_data_types length is
always 0
- plan_err!("Invalid placeholder, not a number: {param}")
+ // FIXME: This branch is shared by params from PREPARE and
CREATE FUNCTION, but
+ // only CREATE FUNCTION currently supports named params.
For now, we rewrite
+ // these to positional params.
+ let named_param_pos = param_data_types
+ .iter()
+ .position(|v| v.name() == ¶m[1..]);
+ match named_param_pos {
+ Some(pos) =>
Ok(Expr::Placeholder(Placeholder::new_with_field(
+ format!("${}", pos + 1),
+ param_data_types.get(pos).cloned(),
+ ))),
+ None => plan_err!("Invalid placeholder: {param}"),
Review Comment:
addressed in
[6be0061](https://github.com/apache/datafusion/pull/18450/commits/6be0061ea74918d5a02a3f56b9d41e3a0ba3452f)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]