Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): make sort respect index #10458

Merged
merged 3 commits into from
Mar 9, 2023
Merged
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
8 changes: 7 additions & 1 deletion src/query/sql/src/planner/binder/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,17 @@ impl Binder {
))
.set_span(order.expr.span()));
}

order_items.push(OrderItem {
expr: order.clone(),
name: projections[index].column_name.clone(),
index: projections[index].index,
need_eval_scalar: false,
need_eval_scalar: scalar_items.get(&projections[index].index).map_or(
false,
|scalar_item| {
!matches!(&scalar_item.scalar, ScalarExpr::BoundColumnRef(_))
},
),
});
}
_ => {
Expand Down
10 changes: 9 additions & 1 deletion tests/sqllogictests/suites/query/order.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ NULL
1
2

query II
select number d , max(1-number) c from numbers(4) group by 1 order by 2;
----
3 -2
2 -1
1 0
0 1


statement ok
drop table order_test

Expand All @@ -36,4 +45,3 @@ select number from numbers(10) as a order by b.number

statement error
select number from (select * from numbers(10) as b) as a order by b.number