comphead commented on code in PR #7922:
URL: https://github.com/apache/arrow-datafusion/pull/7922#discussion_r1370649717
##########
datafusion/sql/src/statement.rs:
##########
@@ -1026,25 +1024,22 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
// Projection
let mut exprs = vec![];
- for (col_name, expr) in values.into_iter() {
+ for (col_name, expr, dt) in values_and_types.into_iter() {
let expr = self.sql_to_expr(expr, &table_schema, &mut
planner_context)?;
let expr = match expr {
datafusion_expr::Expr::Placeholder(Placeholder {
ref id,
ref data_type,
}) => match data_type {
- None => {
- let dt =
table_schema.data_type(&Column::from_name(&col_name))?;
- datafusion_expr::Expr::Placeholder(Placeholder::new(
- id.clone(),
- Some(dt.clone()),
- ))
- }
+ None =>
datafusion_expr::Expr::Placeholder(Placeholder::new(
+ id.clone(),
+ Some(dt.clone()),
+ )),
Some(_) => expr,
},
_ => expr,
};
- let expr = expr.alias(col_name);
+ let expr = expr.cast_to(dt, source.schema())?.alias(col_name);
Review Comment:
will is still cast if datatypes are the same?
--
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]