mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
Added a fix from Vadim Plakhtinskiy @VadimPlh
This commit is contained in:
parent
eb0a1ec755
commit
e6acb35d95
@ -687,8 +687,8 @@ static std::pair<UInt64, UInt64> getLimitLengthAndOffset(const ASTSelectQuery &
|
||||
|
||||
static UInt64 getLimitForSorting(const ASTSelectQuery & query, const Context & context)
|
||||
{
|
||||
/// Partial sort can be done if there is LIMIT but no DISTINCT or LIMIT BY.
|
||||
if (!query.distinct && !query.limitBy() && !query.limit_with_ties)
|
||||
/// Partial sort can be done if there is LIMIT but no DISTINCT or LIMIT BY, neither ARRAY JOIN.
|
||||
if (!query.distinct && !query.limitBy() && !query.limit_with_ties && !query.arrayJoinExpressionList())
|
||||
{
|
||||
auto [limit_length, limit_offset] = getLimitLengthAndOffset(query, context);
|
||||
return limit_length + limit_offset;
|
||||
|
@ -0,0 +1,8 @@
|
||||
['']
|
||||
['']
|
||||
|
||||
|
||||
[]
|
||||
[]
|
||||
['']
|
||||
['']
|
@ -0,0 +1,9 @@
|
||||
SELECT `ParsedParams.Key2` AS x
|
||||
FROM test.hits
|
||||
ARRAY JOIN ParsedParams AS PP
|
||||
ORDER BY x ASC
|
||||
LIMIT 2;
|
||||
|
||||
SELECT arrayJoin(`ParsedParams.Key2`) AS x FROM test.hits ORDER BY x ASC LIMIT 2;
|
||||
WITH arrayJoin(`ParsedParams.Key2`) AS pp SELECT ParsedParams.Key2 AS x FROM test.hits ORDER BY x ASC LIMIT 2;
|
||||
WITH arrayJoin(`ParsedParams.Key2`) AS pp SELECT ParsedParams.Key2 AS x FROM test.hits WHERE NOT ignore(pp) ORDER BY x ASC LIMIT 2;
|
Loading…
Reference in New Issue
Block a user