Skip to content

Commit

Permalink
Simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasrepo committed Dec 27, 2023
1 parent 06adf25 commit e208ebf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 7 additions & 4 deletions datafusion/physical-plan/src/aggregates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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))
Expand Down
12 changes: 6 additions & 6 deletions datafusion/sqllogictest/test_files/groupby.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e208ebf

Please sign in to comment.