phillipleblanc commented on code in PR #12609:
URL: https://github.com/apache/datafusion/pull/12609#discussion_r1774294086
##########
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:
Something like:
```rust
fn format_float(value: f64) -> String {
if value.fract() == 0.0 {
format!("{:.1}", value) // Add ".0" if it's a whole number
} else {
format!("{}", value) // Leave as-is if it already has a decimal
part
}
}
```
--
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]