This is an automated email from the ASF dual-hosted git repository.
jayzhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 31adb083e0 Throw `not_impl_error` for `approx_percentile_cont`
parameters validation (#12133)
31adb083e0 is described below
commit 31adb083e000641d568fe6b3f611d602031e27be
Author: Jax Liu <[email protected]>
AuthorDate: Sat Aug 24 13:14:21 2024 +0800
Throw `not_impl_error` for `approx_percentile_cont` parameters validation
(#12133)
* handle the get scalar value as not_impl_err
* simplify the error handling
---
datafusion/functions-aggregate/src/approx_percentile_cont.rs | 12 +++++++-----
datafusion/sqllogictest/test_files/aggregate.slt | 6 ++++++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/datafusion/functions-aggregate/src/approx_percentile_cont.rs
b/datafusion/functions-aggregate/src/approx_percentile_cont.rs
index 89d827e868..e860783dbe 100644
--- a/datafusion/functions-aggregate/src/approx_percentile_cont.rs
+++ b/datafusion/functions-aggregate/src/approx_percentile_cont.rs
@@ -31,8 +31,8 @@ use arrow::{
use arrow_schema::{Field, Schema};
use datafusion_common::{
- downcast_value, internal_err, not_impl_err, plan_err, DataFusionError,
Result,
- ScalarValue,
+ downcast_value, internal_err, not_impl_datafusion_err, not_impl_err,
plan_err,
+ DataFusionError, Result, ScalarValue,
};
use datafusion_expr::function::{AccumulatorArgs, StateFieldsArgs};
use datafusion_expr::type_coercion::aggregates::{INTEGERS, NUMERICS};
@@ -154,7 +154,8 @@ 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)? {
+ let percentile = match get_scalar_value(expr)
+ .map_err(|_| not_impl_datafusion_err!("Percentile value for
'APPROX_PERCENTILE_CONT' must be a literal, got: {expr}"))? {
ScalarValue::Float32(Some(value)) => {
value as f64
}
@@ -179,7 +180,8 @@ fn validate_input_percentile_expr(expr: &Arc<dyn
PhysicalExpr>) -> Result<f64> {
}
fn validate_input_max_size_expr(expr: &Arc<dyn PhysicalExpr>) -> Result<usize>
{
- let max_size = match get_scalar_value(expr)? {
+ let max_size = match get_scalar_value(expr)
+ .map_err(|_| not_impl_datafusion_err!("Tdigest max_size value for
'APPROX_PERCENTILE_CONT' must be a literal, got: {expr}"))? {
ScalarValue::UInt8(Some(q)) => q as usize,
ScalarValue::UInt16(Some(q)) => q as usize,
ScalarValue::UInt32(Some(q)) => q as usize,
@@ -193,7 +195,7 @@ fn validate_input_max_size_expr(expr: &Arc<dyn
PhysicalExpr>) -> Result<usize> {
"Tdigest max_size value for 'APPROX_PERCENTILE_CONT' must be
UInt > 0 literal (got data type {}).",
sv.data_type()
)
- }
+ },
};
Ok(max_size)
diff --git a/datafusion/sqllogictest/test_files/aggregate.slt
b/datafusion/sqllogictest/test_files/aggregate.slt
index 09fc397bf9..c3609e59f2 100644
--- a/datafusion/sqllogictest/test_files/aggregate.slt
+++ b/datafusion/sqllogictest/test_files/aggregate.slt
@@ -98,6 +98,12 @@ SELECT approx_percentile_cont(c3, 0.95, 111.1) FROM
aggregate_test_100
statement error DataFusion error: Error during planning: Error during
planning: Coercion from \[Float64, Float64, Float64\] to the signature
OneOf(.*) failed(.|\n)*
SELECT approx_percentile_cont(c12, 0.95, 111.1) FROM aggregate_test_100
+statement error DataFusion error: This feature is not implemented: Percentile
value for 'APPROX_PERCENTILE_CONT' must be a literal
+SELECT approx_percentile_cont(c12, c12) FROM aggregate_test_100
+
+statement error DataFusion error: This feature is not implemented: Tdigest
max_size value for 'APPROX_PERCENTILE_CONT' must be a literal
+SELECT approx_percentile_cont(c12, 0.95, c5) FROM aggregate_test_100
+
# array agg can use order by
query ?
SELECT array_agg(c13 ORDER BY c13)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]