Skip to content

Commit

Permalink
Merge pull request duckdb#9477 from hawkfish/window-collate
Browse files Browse the repository at this point in the history
Issue duckdb#8937: Window Order Collation
  • Loading branch information
Mytherin authored Oct 26, 2023
2 parents 626a271 + 5b2ef37 commit b83f3a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/planner/binder/expression/bind_window_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
// failed to bind children of window function
return BindResult(error);
}

// Restore any collation expressions
for (auto &order : window.orders) {
auto &order_expr = order.expression;
auto &bound_order = BoundExpression::GetExpression(*order_expr);
ExpressionBinder::PushCollation(context, bound_order, bound_order->return_type, false);
}
// successfully bound all children: create bound window function
vector<LogicalType> types;
vector<unique_ptr<Expression>> children;
Expand Down
21 changes: 21 additions & 0 deletions test/sql/window/test_window_order_collate.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# name: test/sql/window/test_window_order_collate.test
# description: Test collation is honoured by over(order by)
# group: [window]

statement ok
PRAGMA enable_verification

query III
select
*,
array_agg(col) over(partition by id order by col collate nocase) as lead_col_nocase
from (
select
unnest(array[1, 1, 1, 1]) as id,
unnest(array['A', 'a', 'b', 'B']) as col
)
----
1 A [A, a]
1 a [A, a]
1 b [A, a, b, B]
1 B [A, a, b, B]

0 comments on commit b83f3a0

Please sign in to comment.