Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
7411d6b
Naive test pass
mustafasrepo May 3, 2023
87c397d
Add new tests and simplifications
mustafasrepo May 3, 2023
ebd0e5f
move tests to the .slt file
mustafasrepo May 4, 2023
ecc5b0d
update requirement
mustafasrepo May 4, 2023
7093fa7
update tests
mustafasrepo May 5, 2023
e377ea9
Add support for partiallyOrdered aggregation sensitive.
mustafasrepo May 5, 2023
e0ce989
Resolve linter errors
mustafasrepo May 5, 2023
e3edf7c
Merge branch 'main' into feature/ordering_sensitive_aggregation
mustafasrepo May 5, 2023
550416e
update comments
mustafasrepo May 5, 2023
d72cc8f
minor changes
mustafasrepo May 5, 2023
713b56b
Merge branch 'main' into feature/ordering_sensitive_aggregation
mustafasrepo May 5, 2023
3dcf079
retract changes in generated
mustafasrepo May 5, 2023
a817887
update proto files
mustafasrepo May 5, 2023
740a605
Simplifications
ozankabak May 6, 2023
8209c46
Make types consistent in schema, and data
mustafasrepo May 8, 2023
d93b187
Update todos
mustafasrepo May 8, 2023
5bb8dde
Convert API to vector
mustafasrepo May 8, 2023
72985f8
Convert get_finest to handle Vector inputs
mustafasrepo May 9, 2023
4ae5c25
simplifications, update comment
mustafasrepo May 9, 2023
6fd96da
initial commit, add test
mustafasrepo May 9, 2023
0a52150
Merge branch 'main' into feature/ordering_sensitive_aggregation
mustafasrepo May 10, 2023
61cc109
Add support for FIRST Aggregate function.
mustafasrepo May 9, 2023
682b1f4
Add support for last aggregate
mustafasrepo May 10, 2023
670a327
Update cargo.lock
mustafasrepo May 10, 2023
4c27b85
Remove distinct, and limit from First and last aggregate.
mustafasrepo May 10, 2023
e9535bd
Add reverse for First and Last Aggregator
mustafasrepo May 10, 2023
2143b72
Update cargo lock
mustafasrepo May 10, 2023
10e7811
Merge branch 'feature/ordering_sensitive_aggregation' into feature/fi…
mustafasrepo May 10, 2023
c59ce9b
Minor code simplifications
ozankabak May 11, 2023
90aa195
Update comment
mustafasrepo May 11, 2023
9abfe65
Update documents
mustafasrepo May 11, 2023
0527c20
Merge branch 'main' into feature/first_last_aggregate
mustafasrepo May 12, 2023
8456a8d
Merge branch 'apache:main' into feature/ordering_sensitive_aggregation
mustafasrepo May 12, 2023
a4eced0
Fix projection pushdown bug
mustafasrepo May 12, 2023
344e184
fix projection push down failure bug
mustafasrepo May 12, 2023
2d1482d
Merge branch 'feature/ordering_sensitive_aggregation' into feature/fi…
mustafasrepo May 12, 2023
9d01d4d
combine first_agg and last_agg parsers
mustafasrepo May 12, 2023
9be10fb
Merge branch 'main' into feature/first_last_aggregate
mustafasrepo May 16, 2023
8fc5b82
Update documentation
mustafasrepo May 16, 2023
2ac73d6
Update subproject
mustafasrepo May 16, 2023
dbe0826
initial commit
mustafasrepo May 18, 2023
118fa92
Add test code
mustafasrepo May 18, 2023
228d973
initial version
mustafasrepo May 18, 2023
c9cca16
simplify prints
mustafasrepo May 18, 2023
8a87fdb
minor changes
mustafasrepo May 18, 2023
1db5683
sqllogictests pass
mustafasrepo May 18, 2023
2b2ae1d
All tests pass
mustafasrepo May 18, 2023
2804350
update proto function names
mustafasrepo May 18, 2023
e5a2776
Minor changes
mustafasrepo May 18, 2023
0889165
Merge branch 'main' into feature/first_last_aggregate2
mustafasrepo May 22, 2023
af4d209
do not consider ordering requirement in ordering insensitive aggregators
mustafasrepo May 22, 2023
eacfaff
Reject aggregate order by for window functions.
mustafasrepo May 22, 2023
4ce1038
simplifications
mustafasrepo May 23, 2023
148dec2
Merge branch 'main' into feature/first_last_aggregate2
mustafasrepo May 23, 2023
1bdda38
Fix cargo lock file
mustafasrepo May 23, 2023
fab0dcd
Merge branch 'main' into feature/first_last_aggregate2
mustafasrepo May 23, 2023
94fe486
Update comment
mustafasrepo May 24, 2023
13ee806
Rename aggregator first and last
mustafasrepo May 24, 2023
1cd494f
minor change
berkaysynnada May 24, 2023
f2a0a68
Comment improvements
ozankabak May 25, 2023
c4a47e2
Remove count from First,Last accumulators
mustafasrepo May 25, 2023
c20ca75
Merge branch 'main' into feature/first_last_aggregate2
mustafasrepo May 26, 2023
d140e97
Merge branch 'main' into feature/first_last_aggregate2
mustafasrepo May 26, 2023
18935b2
Address reviews
mustafasrepo May 26, 2023
48057cc
Remove camel to upper snake util, make aggregate function names explicit
mustafasrepo May 26, 2023
5cc149a
update the test
mustafasrepo May 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion datafusion/core/src/physical_plan/aggregates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mod utils;

pub use datafusion_expr::AggregateFunction;
pub use datafusion_physical_expr::expressions::create_aggregate_expr;
use datafusion_physical_expr::expressions::{ArrayAgg, FirstValue, LastValue};

/// Hash aggregate modes
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -388,14 +389,24 @@ fn get_finest_requirement<
Ok(result)
}

/// Checks whether the given aggregate expression is order-sensitive.
/// For instance, a `SUM` aggregation doesn't depend on the order of its inputs.
/// However, a `FirstAgg` depends on the input ordering (if the order changes,
/// the first value in the list would change).
fn is_order_sensitive(aggr_expr: &Arc<dyn AggregateExpr>) -> bool {
aggr_expr.as_any().is::<FirstValue>()
|| aggr_expr.as_any().is::<LastValue>()
|| aggr_expr.as_any().is::<ArrayAgg>()
}

impl AggregateExec {
/// Create a new hash aggregate execution plan
pub fn try_new(
mode: AggregateMode,
group_by: PhysicalGroupBy,
aggr_expr: Vec<Arc<dyn AggregateExpr>>,
filter_expr: Vec<Option<Arc<dyn PhysicalExpr>>>,
order_by_expr: Vec<Option<Vec<PhysicalSortExpr>>>,
mut order_by_expr: Vec<Option<Vec<PhysicalSortExpr>>>,
input: Arc<dyn ExecutionPlan>,
input_schema: SchemaRef,
) -> Result<Self> {
Expand All @@ -413,6 +424,18 @@ impl AggregateExec {
// In other modes, all groups are collapsed, therefore their input schema
// can not contain expressions in the requirement.
if mode == AggregateMode::Partial || mode == AggregateMode::Single {
order_by_expr = aggr_expr
.iter()
.zip(order_by_expr.into_iter())
.map(|(aggr_expr, fn_reqs)| {
// If aggregation function is ordering sensitive, keep ordering requirement as is; otherwise ignore requirement
if is_order_sensitive(aggr_expr) {
fn_reqs
} else {
None
}
})
.collect::<Vec<_>>();
let requirement = get_finest_requirement(
&order_by_expr,
|| input.equivalence_properties(),
Expand Down
20 changes: 10 additions & 10 deletions datafusion/core/tests/dataframe_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ async fn test_fn_approx_median() -> Result<()> {
let expr = approx_median(col("b"));

let expected = vec![
"+----------------------+",
"| APPROXMEDIAN(test.b) |",
"+----------------------+",
"| 10 |",
"+----------------------+",
"+-----------------------+",
Copy link
Contributor Author

@mustafasrepo mustafasrepo May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As part of this PR, I have added convert_camel_to_upper_snake util for displaying Aggregate functions. Their display name is automatically, calculated from struct name. Hence display name of some of the existing aggregators is changed(such as APPROXMEDIAN became APPROX_MEDIAN, ARRAYAGG became ARRAY_AGG, etc).

"| APPROX_MEDIAN(test.b) |",
"+-----------------------+",
"| 10 |",
"+-----------------------+",
];

let df = create_test_table().await?;
Expand All @@ -175,11 +175,11 @@ async fn test_fn_approx_percentile_cont() -> Result<()> {
let expr = approx_percentile_cont(col("b"), lit(0.5));

let expected = vec![
"+-------------------------------------------+",
"| APPROXPERCENTILECONT(test.b,Float64(0.5)) |",
"+-------------------------------------------+",
"| 10 |",
"+-------------------------------------------+",
"+---------------------------------------------+",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is nice -- it makes the aggregates consistent with the (very) recent change from @2010YOUY01 for scalar functions: #6448

"| APPROX_PERCENTILE_CONT(test.b,Float64(0.5)) |",
"+---------------------------------------------+",
"| 10 |",
"+---------------------------------------------+",
];

let df = create_test_table().await?;
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/tests/sql/aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ async fn csv_query_array_agg_distinct() -> Result<()> {

// The results for this query should be something like the following:
// +------------------------------------------+
// | ARRAYAGG(DISTINCT aggregate_test_100.c2) |
// | ARRAY_AGG(DISTINCT aggregate_test_100.c2) |
// +------------------------------------------+
// | [4, 2, 3, 5, 1] |
// +------------------------------------------+
// Since ARRAY_AGG(DISTINCT) ordering is nondeterministic, check the schema and contents.
assert_eq!(
*actual[0].schema(),
Schema::new(vec![Field::new_list(
"ARRAYAGG(DISTINCT aggregate_test_100.c2)",
"ARRAY_AGG(DISTINCT aggregate_test_100.c2)",
Field::new("item", DataType::UInt32, true),
false
),])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ LOCATION '../../testing/data/csv/aggregate_test_100.csv'
#######

# https://github.com/apache/arrow-datafusion/issues/3353
statement error DataFusion error: Schema error: Schema contains duplicate unqualified field name "APPROXDISTINCT\(aggregate_test_100\.c9\)"
statement error DataFusion error: Schema error: Schema contains duplicate unqualified field name "APPROX_DISTINCT\(aggregate_test_100\.c9\)"
SELECT approx_distinct(c9) count_c9, approx_distinct(cast(c9 as varchar)) count_c9_str FROM aggregate_test_100

# csv_query_approx_percentile_cont_with_weight
Expand Down
140 changes: 110 additions & 30 deletions datafusion/core/tests/sqllogictests/test_files/groupby.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1974,25 +1974,26 @@ query III


# test_source_sorted_groupby2

# If ordering is not important for the aggregation function, we should ignore the ordering requirement. Hence
# "ORDER BY a DESC" should have no effect.
query TT
EXPLAIN SELECT a, d,
SUM(c) as summation1
SUM(c ORDER BY a DESC) as summation1
FROM annotated_data_infinite2
GROUP BY d, a
----
logical_plan
Projection: annotated_data_infinite2.a, annotated_data_infinite2.d, SUM(annotated_data_infinite2.c) AS summation1
--Aggregate: groupBy=[[annotated_data_infinite2.d, annotated_data_infinite2.a]], aggr=[[SUM(annotated_data_infinite2.c)]]
Projection: annotated_data_infinite2.a, annotated_data_infinite2.d, SUM(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST] AS summation1
--Aggregate: groupBy=[[annotated_data_infinite2.d, annotated_data_infinite2.a]], aggr=[[SUM(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST]]]
----TableScan: annotated_data_infinite2 projection=[a, c, d]
physical_plan
ProjectionExec: expr=[a@1 as a, d@0 as d, SUM(annotated_data_infinite2.c)@2 as summation1]
ProjectionExec: expr=[a@1 as a, d@0 as d, SUM(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST]@2 as summation1]
--AggregateExec: mode=Single, gby=[d@2 as d, a@0 as a], aggr=[SUM(annotated_data_infinite2.c)], ordering_mode=PartiallyOrdered
----CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, c, d], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST], has_header=true

query III
SELECT a, d,
SUM(c) as summation1
SUM(c ORDER BY a DESC) as summation1
FROM annotated_data_infinite2
GROUP BY d, a
----
Expand All @@ -2007,6 +2008,85 @@ SELECT a, d,
1 4 913
1 2 848

# test_source_sorted_groupby3

query TT
EXPLAIN SELECT a, b, FIRST_VALUE(c ORDER BY a DESC) as first_c
FROM annotated_data_infinite2
GROUP BY a, b
----
logical_plan
Projection: annotated_data_infinite2.a, annotated_data_infinite2.b, FIRST_VALUE(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST] AS first_c
--Aggregate: groupBy=[[annotated_data_infinite2.a, annotated_data_infinite2.b]], aggr=[[FIRST_VALUE(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST]]]
----TableScan: annotated_data_infinite2 projection=[a, b, c]
physical_plan
ProjectionExec: expr=[a@0 as a, b@1 as b, FIRST_VALUE(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST]@2 as first_c]
--AggregateExec: mode=Single, gby=[a@0 as a, b@1 as b], aggr=[FIRST_VALUE(annotated_data_infinite2.c)], ordering_mode=FullyOrdered
----CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b, c], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST, b@1 ASC NULLS LAST, c@2 ASC NULLS LAST], has_header=true

query III
SELECT a, b, FIRST_VALUE(c ORDER BY a DESC) as first_c
FROM annotated_data_infinite2
GROUP BY a, b
----
0 0 0
0 1 25
1 2 50
1 3 75

# test_source_sorted_groupby4

query TT
EXPLAIN SELECT a, b, LAST_VALUE(c ORDER BY a DESC) as last_c
FROM annotated_data_infinite2
GROUP BY a, b
----
logical_plan
Projection: annotated_data_infinite2.a, annotated_data_infinite2.b, LAST_VALUE(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST] AS last_c
--Aggregate: groupBy=[[annotated_data_infinite2.a, annotated_data_infinite2.b]], aggr=[[LAST_VALUE(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST]]]
----TableScan: annotated_data_infinite2 projection=[a, b, c]
physical_plan
ProjectionExec: expr=[a@0 as a, b@1 as b, LAST_VALUE(annotated_data_infinite2.c) ORDER BY [annotated_data_infinite2.a DESC NULLS FIRST]@2 as last_c]
--AggregateExec: mode=Single, gby=[a@0 as a, b@1 as b], aggr=[LAST_VALUE(annotated_data_infinite2.c)], ordering_mode=FullyOrdered
----CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b, c], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST, b@1 ASC NULLS LAST, c@2 ASC NULLS LAST], has_header=true

query III
SELECT a, b, LAST_VALUE(c ORDER BY a DESC) as last_c
FROM annotated_data_infinite2
GROUP BY a, b
----
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
# not deterministic
query TT
EXPLAIN SELECT a, b, LAST_VALUE(c) as last_c
FROM annotated_data_infinite2
GROUP BY a, b
----
logical_plan
Projection: annotated_data_infinite2.a, annotated_data_infinite2.b, LAST_VALUE(annotated_data_infinite2.c) AS last_c
--Aggregate: groupBy=[[annotated_data_infinite2.a, annotated_data_infinite2.b]], aggr=[[LAST_VALUE(annotated_data_infinite2.c)]]
----TableScan: annotated_data_infinite2 projection=[a, b, c]
physical_plan
ProjectionExec: expr=[a@0 as a, b@1 as b, LAST_VALUE(annotated_data_infinite2.c)@2 as last_c]
--AggregateExec: mode=Single, gby=[a@0 as a, b@1 as b], aggr=[LAST_VALUE(annotated_data_infinite2.c)], ordering_mode=FullyOrdered
----CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b, c], infinite_source=true, output_ordering=[a@0 ASC NULLS LAST, b@1 ASC NULLS LAST, c@2 ASC NULLS LAST], has_header=true

query III
SELECT a, b, LAST_VALUE(c) as last_c
FROM annotated_data_infinite2
GROUP BY a, b
----
0 0 24
0 1 49
1 2 74
1 3 99

statement ok
drop table annotated_data_infinite2;

Expand Down Expand Up @@ -2038,12 +2118,12 @@ EXPLAIN SELECT country, (ARRAY_AGG(amount ORDER BY amount ASC)) AS amounts
GROUP BY country
----
logical_plan
Projection: sales_global.country, ARRAYAGG(sales_global.amount) ORDER BY [sales_global.amount ASC NULLS LAST] AS amounts
--Aggregate: groupBy=[[sales_global.country]], aggr=[[ARRAYAGG(sales_global.amount) ORDER BY [sales_global.amount ASC NULLS LAST]]]
Projection: sales_global.country, ARRAY_AGG(sales_global.amount) ORDER BY [sales_global.amount ASC NULLS LAST] AS amounts
--Aggregate: groupBy=[[sales_global.country]], aggr=[[ARRAY_AGG(sales_global.amount) ORDER BY [sales_global.amount ASC NULLS LAST]]]
----TableScan: sales_global projection=[country, amount]
physical_plan
ProjectionExec: expr=[country@0 as country, ARRAYAGG(sales_global.amount) ORDER BY [sales_global.amount ASC NULLS LAST]@1 as amounts]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAYAGG(sales_global.amount)]
ProjectionExec: expr=[country@0 as country, ARRAY_AGG(sales_global.amount) ORDER BY [sales_global.amount ASC NULLS LAST]@1 as amounts]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAY_AGG(sales_global.amount)]
----SortExec: expr=[amount@1 ASC NULLS LAST]
------MemoryExec: partitions=1, partition_sizes=[1]

Expand All @@ -2067,13 +2147,13 @@ EXPLAIN SELECT s.country, ARRAY_AGG(s.amount ORDER BY s.amount DESC) AS amounts,
GROUP BY s.country
----
logical_plan
Projection: s.country, ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST], SUM(s.amount)]]
Projection: s.country, ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST], SUM(s.amount)]]
----SubqueryAlias: s
------TableScan: sales_global projection=[country, amount]
physical_plan
ProjectionExec: expr=[country@0 as country, ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAYAGG(s.amount), SUM(s.amount)]
ProjectionExec: expr=[country@0 as country, ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAY_AGG(s.amount), SUM(s.amount)]
----SortExec: expr=[amount@1 DESC]
------MemoryExec: partitions=1, partition_sizes=[1]

Expand Down Expand Up @@ -2120,14 +2200,14 @@ EXPLAIN SELECT s.country, ARRAY_AGG(s.amount ORDER BY s.amount DESC) AS amounts,
GROUP BY s.country
----
logical_plan
Projection: s.country, ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST], SUM(s.amount)]]
Projection: s.country, ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST], SUM(s.amount)]]
----SubqueryAlias: s
------Sort: sales_global.country ASC NULLS LAST
--------TableScan: sales_global projection=[country, amount]
physical_plan
ProjectionExec: expr=[country@0 as country, ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAYAGG(s.amount), SUM(s.amount)], ordering_mode=FullyOrdered
ProjectionExec: expr=[country@0 as country, ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAY_AGG(s.amount), SUM(s.amount)], ordering_mode=FullyOrdered
----SortExec: expr=[country@0 ASC NULLS LAST,amount@1 DESC]
------MemoryExec: partitions=1, partition_sizes=[1]

Expand Down Expand Up @@ -2156,14 +2236,14 @@ EXPLAIN SELECT s.country, s.zip_code, ARRAY_AGG(s.amount ORDER BY s.amount DESC)
GROUP BY s.country, s.zip_code
----
logical_plan
Projection: s.country, s.zip_code, ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country, s.zip_code]], aggr=[[ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST], SUM(s.amount)]]
Projection: s.country, s.zip_code, ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country, s.zip_code]], aggr=[[ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST], SUM(s.amount)]]
----SubqueryAlias: s
------Sort: sales_global.country ASC NULLS LAST
--------TableScan: sales_global projection=[zip_code, country, amount]
physical_plan
ProjectionExec: expr=[country@0 as country, zip_code@1 as zip_code, ARRAYAGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST]@2 as amounts, SUM(s.amount)@3 as sum1]
--AggregateExec: mode=Single, gby=[country@1 as country, zip_code@0 as zip_code], aggr=[ARRAYAGG(s.amount), SUM(s.amount)], ordering_mode=PartiallyOrdered
ProjectionExec: expr=[country@0 as country, zip_code@1 as zip_code, ARRAY_AGG(s.amount) ORDER BY [s.amount DESC NULLS FIRST]@2 as amounts, SUM(s.amount)@3 as sum1]
--AggregateExec: mode=Single, gby=[country@1 as country, zip_code@0 as zip_code], aggr=[ARRAY_AGG(s.amount), SUM(s.amount)], ordering_mode=PartiallyOrdered
----SortExec: expr=[country@1 ASC NULLS LAST,amount@2 DESC]
------MemoryExec: partitions=1, partition_sizes=[1]

Expand Down Expand Up @@ -2192,14 +2272,14 @@ EXPLAIN SELECT s.country, ARRAY_AGG(s.amount ORDER BY s.country DESC) AS amounts
GROUP BY s.country
----
logical_plan
Projection: s.country, ARRAYAGG(s.amount) ORDER BY [s.country DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAYAGG(s.amount) ORDER BY [s.country DESC NULLS FIRST], SUM(s.amount)]]
Projection: s.country, ARRAY_AGG(s.amount) ORDER BY [s.country DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAY_AGG(s.amount) ORDER BY [s.country DESC NULLS FIRST], SUM(s.amount)]]
----SubqueryAlias: s
------Sort: sales_global.country ASC NULLS LAST
--------TableScan: sales_global projection=[country, amount]
physical_plan
ProjectionExec: expr=[country@0 as country, ARRAYAGG(s.amount) ORDER BY [s.country DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAYAGG(s.amount), SUM(s.amount)], ordering_mode=FullyOrdered
ProjectionExec: expr=[country@0 as country, ARRAY_AGG(s.amount) ORDER BY [s.country DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAY_AGG(s.amount), SUM(s.amount)], ordering_mode=FullyOrdered
----SortExec: expr=[country@0 ASC NULLS LAST]
------MemoryExec: partitions=1, partition_sizes=[1]

Expand Down Expand Up @@ -2227,14 +2307,14 @@ EXPLAIN SELECT s.country, ARRAY_AGG(s.amount ORDER BY s.country DESC, s.amount D
GROUP BY s.country
----
logical_plan
Projection: s.country, ARRAYAGG(s.amount) ORDER BY [s.country DESC NULLS FIRST, s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAYAGG(s.amount) ORDER BY [s.country DESC NULLS FIRST, s.amount DESC NULLS FIRST], SUM(s.amount)]]
Projection: s.country, ARRAY_AGG(s.amount) ORDER BY [s.country DESC NULLS FIRST, s.amount DESC NULLS FIRST] AS amounts, SUM(s.amount) AS sum1
--Aggregate: groupBy=[[s.country]], aggr=[[ARRAY_AGG(s.amount) ORDER BY [s.country DESC NULLS FIRST, s.amount DESC NULLS FIRST], SUM(s.amount)]]
----SubqueryAlias: s
------Sort: sales_global.country ASC NULLS LAST
--------TableScan: sales_global projection=[country, amount]
physical_plan
ProjectionExec: expr=[country@0 as country, ARRAYAGG(s.amount) ORDER BY [s.country DESC NULLS FIRST, s.amount DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAYAGG(s.amount), SUM(s.amount)], ordering_mode=FullyOrdered
ProjectionExec: expr=[country@0 as country, ARRAY_AGG(s.amount) ORDER BY [s.country DESC NULLS FIRST, s.amount DESC NULLS FIRST]@1 as amounts, SUM(s.amount)@2 as sum1]
--AggregateExec: mode=Single, gby=[country@0 as country], aggr=[ARRAY_AGG(s.amount), SUM(s.amount)], ordering_mode=FullyOrdered
----SortExec: expr=[country@0 ASC NULLS LAST,amount@1 DESC]
------MemoryExec: partitions=1, partition_sizes=[1]

Expand Down
Loading