phillipleblanc commented on code in PR #12609: URL: https://github.com/apache/datafusion/pull/12609#discussion_r1774284699
########## datafusion/sql/src/unparser/expr.rs: ########## @@ -952,13 +952,25 @@ impl Unparser<'_> { Ok(ast::Expr::Value(ast::Value::Number(f.to_string(), false))) } ScalarValue::Float16(None) => Ok(ast::Expr::Value(ast::Value::Null)), - ScalarValue::Float32(Some(f)) => { - Ok(ast::Expr::Value(ast::Value::Number(f.to_string(), false))) - } + ScalarValue::Float32(Some(f)) => Ok(ast::Expr::Cast { + kind: ast::CastKind::Cast, + expr: Box::new(ast::Expr::Value(ast::Value::Number( + f.to_string(), + false, + ))), + data_type: self.arrow_dtype_to_ast_dtype(&DataType::Float32)?, + format: None, + }), Review Comment: This solves the problem of keeping the float literal types intact when generating SQL to execute against remote systems, but it also has the side effect of making the generated SQL a bit less human readable. Instead of just calling `.to_string()` on the float literal, which chops off the decimal portion if it doesn't exist - could we format it to always contain a decimal portion? i.e. `3` -> `3.0`. That should solve the problem and keep the generated SQL easier to understand by humans. -- 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...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org