alamb commented on code in PR #4977: URL: https://github.com/apache/arrow-datafusion/pull/4977#discussion_r1082377502
########## datafusion/sql/src/statement.rs: ########## @@ -762,8 +762,34 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { let arrow_schema = (*provider.schema()).clone(); let table_schema = Arc::new(DFSchema::try_from(arrow_schema)?); + // infer types for Values clause... other types should be resolvable the regular way + let mut prepare_param_data_types = BTreeMap::new(); + if let SetExpr::Values(ast::Values { rows, .. }) = (*source.body).clone() { + for row in rows.iter() { + for (idx, val) in row.iter().enumerate() { + if let ast::Expr::Value(Value::Placeholder(name)) = val { + let name = + name.replace('$', "").parse::<usize>().map_err(|_| { + DataFusionError::Plan(format!( + "Can't parse placeholder: {name}" + )) + })? - 1; + let col = columns.get(idx).ok_or_else(|| { + DataFusionError::Plan("Column not found".to_string()) Review Comment: I think it would help here to be a bit more specific with the message: ```suggestion DataFusionError::Plan(format!("Placeholder ${idx} refers to a non existent column") ``` Or something -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org