You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2024/08/23 16:24:55 UTC
Re: [PR] Throw `not_impl_error` for `approx_percentile_cont` parameters validation [datafusion]
alamb commented on code in PR #12133:
URL: https://github.com/apache/datafusion/pull/12133#discussion_r1729223545
##########
datafusion/functions-aggregate/src/approx_percentile_cont.rs:
##########
@@ -154,19 +154,20 @@ fn get_scalar_value(expr: &Arc<dyn PhysicalExpr>) -> Result<ScalarValue> {
}
fn validate_input_percentile_expr(expr: &Arc<dyn PhysicalExpr>) -> Result<f64> {
- let percentile = match get_scalar_value(expr)? {
- ScalarValue::Float32(Some(value)) => {
+ let percentile = match get_scalar_value(expr).ok() {
Review Comment:
Another way to express this for your consideration that might make the error handling more obvious is
```rust
let scalar = match get_scalar_value(expr)
.map_err(not_impl_err!("Percentile value for 'APPROX_PERCENTILE_CONT' must be a litera, got: {expr}l")?
match scalar {
ScalarValue::Float32(Some(value)) => {
...
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org