mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #11689 from CurtizJ/fix-with-ties
Fix 'LIMIT WITH TIES' with aliases
This commit is contained in:
commit
82b27ab618
@ -973,6 +973,14 @@ void InterpreterSelectQuery::executeImpl(QueryPipeline & pipeline, const BlockIn
|
||||
|
||||
executeWithFill(pipeline);
|
||||
|
||||
/// If we have 'WITH TIES', we need execute limit before projection,
|
||||
/// because in that case columns from 'ORDER BY' are used.
|
||||
if (query.limit_with_ties)
|
||||
{
|
||||
executeLimit(pipeline);
|
||||
has_prelimit = true;
|
||||
}
|
||||
|
||||
/** We must do projection after DISTINCT because projection may remove some columns.
|
||||
*/
|
||||
executeProjection(pipeline, expressions.final_projection);
|
||||
|
@ -0,0 +1,25 @@
|
||||
0 0
|
||||
1 0
|
||||
2 0
|
||||
3 0
|
||||
4 0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
0 0
|
||||
0 1
|
||||
0 2
|
||||
0 3
|
||||
0 4
|
||||
0 0
|
||||
0 1
|
||||
0 2
|
||||
0 3
|
||||
0 4
|
12
tests/queries/0_stateless/01142_with_ties_and_aliases.sql
Normal file
12
tests/queries/0_stateless/01142_with_ties_and_aliases.sql
Normal file
@ -0,0 +1,12 @@
|
||||
select number, intDiv(number,5) value from numbers(20) order by value limit 3 with ties;
|
||||
|
||||
drop table if exists wt;
|
||||
create table wt (a Int, b Int) engine = Memory;
|
||||
insert into wt select 0, number from numbers(5);
|
||||
|
||||
select 1 from wt order by a limit 3 with ties;
|
||||
select b from wt order by a limit 3 with ties;
|
||||
with a * 2 as c select a, b from wt order by c limit 3 with ties;
|
||||
select a * 2 as c, b from wt order by c limit 3 with ties;
|
||||
|
||||
drop table if exists wt;
|
Loading…
Reference in New Issue
Block a user