Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 4 additions & 8 deletions datafusion/sql/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use datafusion_common::error::DataFusionErrorBuilder;
use datafusion_common::tree_node::{TreeNode, TreeNodeRecursion};
use datafusion_common::{Column, DFSchema, Result, not_impl_err, plan_err};
use datafusion_common::{RecursionUnnestOption, UnnestOptions};
use datafusion_expr::expr::{Alias, PlannedReplaceSelectItem, WildcardOptions};
use datafusion_expr::expr::{PlannedReplaceSelectItem, WildcardOptions};
use datafusion_expr::expr_rewriter::{
normalize_col, normalize_col_with_schemas_and_ambiguity_check, normalize_sorts,
};
Expand Down Expand Up @@ -193,15 +193,11 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
.collect::<Result<Vec<Expr>>>()?
} else {
// 'group by all' groups wrt. all select expressions except 'AggregateFunction's.
// Filter and collect non-aggregate select expressions
// Filter and collect non-aggregate select expressions.
select_exprs
.iter()
.filter(|select_expr| match select_expr {
Expr::AggregateFunction(_) => false,
Expr::Alias(Alias { expr, name: _, .. }) => {
!matches!(**expr, Expr::AggregateFunction(_))
}
_ => true,
.filter(|select_expr| {
find_aggregate_exprs(std::iter::once(*select_expr)).is_empty()
})
.cloned()
.collect()
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sqllogictest/test_files/group_by.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,11 @@ SELECT col0, col1, COUNT(col2), SUM(col3) FROM tab3 GROUP BY ALL
0 2 2 -3
1 NULL 1 -2

query I
SELECT COUNT(*) AS c FROM tab3 GROUP BY ALL
----
5

# query below should work in multi partition, successfully.
query II
SELECT l.col0, LAST_VALUE(r.col1 ORDER BY r.col0) as last_col1
Expand Down
Loading