Make the query planner respect LIMIT BY in remote queries

This commit is contained in:
Constantin S. Pan 2019-03-15 15:22:22 +00:00
parent c39c32973c
commit df6860d5e0
3 changed files with 14 additions and 0 deletions

View File

@ -623,6 +623,12 @@ void InterpreterSelectQuery::executeImpl(Pipeline & pipeline, const BlockInputSt
if (expressions.has_order_by && query.limit_length)
executeDistinct(pipeline, false, expressions.selected_columns);
if (expressions.has_limit_by)
{
executeExpression(pipeline, expressions.before_limit_by);
executeLimitBy(pipeline);
}
if (query.limit_length)
executePreLimit(pipeline);
}

View File

@ -19,3 +19,8 @@
0
0
1
100
100
101
101
102

View File

@ -29,4 +29,7 @@ SELECT dummy FROM remote('127.0.0.{2,3}', system.one) LIMIT 2 BY dummy;
SELECT 1 as one FROM remote('127.0.0.{2,3}', system.one) LIMIT 1 BY one;
-- Distributed LIMIT BY with LIMIT
SELECT toInt8(number / 5 + 100) AS x FROM remote('127.0.0.1', system.numbers) LIMIT 2 BY x LIMIT 5;
DROP TABLE IF EXISTS test.limit_by;