From e208ebff30586da6d7093a4961ee4cc1e1a5e194 Mon Sep 17 00:00:00 2001 From: Mustafa Akur Date: Wed, 27 Dec 2023 15:28:56 +0300 Subject: [PATCH] Simplifications --- datafusion/physical-plan/src/aggregates/mod.rs | 11 +++++++---- datafusion/sqllogictest/test_files/groupby.slt | 12 ++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index 5f8d85b06fb6..6a15fc33be35 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -38,7 +38,7 @@ use arrow::datatypes::{Field, Schema, SchemaRef}; use arrow::record_batch::RecordBatch; use arrow_schema::DataType; use datafusion_common::stats::Precision; -use datafusion_common::{plan_datafusion_err, plan_err, DataFusionError, Result}; +use datafusion_common::{not_impl_err, plan_err, DataFusionError, Result}; use datafusion_execution::TaskContext; use datafusion_expr::Accumulator; use datafusion_physical_expr::{ @@ -918,9 +918,12 @@ fn get_aggregate_exprs_requirement( { requirement = finer_ordering; } else { - return Err(plan_datafusion_err!( - "Conflicting ordering requirement is not supported" - )); + // If neither of the requirements satisfy the other, this means + // requirements are conflicting. Currently, we do not support + // conflicting requirements. + return not_impl_err!( + "Conflicting ordering requirements in aggregate functions is not supported" + ); } } Ok(PhysicalSortRequirement::from_sort_exprs(&requirement)) diff --git a/datafusion/sqllogictest/test_files/groupby.slt b/datafusion/sqllogictest/test_files/groupby.slt index c4805c777cf3..bbf21e135fe4 100644 --- a/datafusion/sqllogictest/test_files/groupby.slt +++ b/datafusion/sqllogictest/test_files/groupby.slt @@ -2208,14 +2208,14 @@ ProjectionExec: expr=[a@0 as a, b@1 as b, LAST_VALUE(annotated_data_infinite2.c) ----StreamingTableExec: partition_sizes=1, projection=[a, b, c], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST, b@1 ASC NULLS LAST, c@2 ASC NULLS LAST] query III -SELECT a, b, LAST_VALUE(c ORDER BY a DESC) as last_c +SELECT a, b, LAST_VALUE(c ORDER BY a DESC, c ASC) as last_c FROM annotated_data_infinite2 GROUP BY a, b ---- -0 0 0 -0 1 25 -1 2 50 -1 3 75 +0 0 24 +0 1 49 +1 2 74 +1 3 99 # when LAST_VALUE, or FIRST_VALUE value do not contain ordering requirement # queries should still work, However, result depends on the scanning order and @@ -2342,7 +2342,7 @@ TUR [100.0, 75.0] 175 # test_ordering_sensitive_aggregation3 # When different aggregators have conflicting requirements, we cannot satisfy all of them in current implementation. # test below should raise Plan Error. -statement error DataFusion error: Error during planning: Conflicting ordering requirement is not supported +statement error DataFusion error: This feature is not implemented: Conflicting ordering requirements in aggregate functions is not supported SELECT ARRAY_AGG(s.amount ORDER BY s.amount DESC) AS amounts, ARRAY_AGG(s.amount ORDER BY s.amount ASC) AS amounts2, ARRAY_AGG(s.amount ORDER BY s.sn ASC) AS amounts3