mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
update tests
This commit is contained in:
parent
f99622be33
commit
13bb3774ff
@ -319,7 +319,7 @@ void optimizeDuplicateOrderBy(ASTPtr & query, const Context & context)
|
||||
DuplicateOrderByVisitor(order_by_data).visit(query);
|
||||
}
|
||||
|
||||
/// Return simple subselect (without UNIONs or JOINs) if any
|
||||
/// Return simple subselect (without UNIONs or JOINs or SETTINGS) if any
|
||||
const ASTSelectQuery * getSimpleSubselect(const ASTSelectQuery & select)
|
||||
{
|
||||
if (!select.tables())
|
||||
@ -346,7 +346,11 @@ const ASTSelectQuery * getSimpleSubselect(const ASTSelectQuery & select)
|
||||
subselect_union->list_of_selects->children.size() != 1)
|
||||
return nullptr;
|
||||
|
||||
return subselect_union->list_of_selects->children[0]->as<ASTSelectQuery>();
|
||||
const auto & subselect = subselect_union->list_of_selects->children[0]->as<ASTSelectQuery>();
|
||||
if (subselect && subselect->settings())
|
||||
return nullptr;
|
||||
|
||||
return subselect;
|
||||
}
|
||||
|
||||
std::unordered_set<String> getDistinctNames(const ASTSelectQuery & select)
|
||||
@ -652,7 +656,11 @@ void TreeOptimizer::apply(ASTPtr & query, Aliases & aliases, const NameSet & sou
|
||||
if (settings.optimize_duplicate_order_by_and_distinct)
|
||||
{
|
||||
optimizeDuplicateOrderBy(query, context);
|
||||
optimizeDuplicateDistinct(*select_query);
|
||||
|
||||
/// DISTINCT has special meaning in Distributed query with enabled distributed_group_by_no_merge
|
||||
/// TODO: disable Distributed/remote() tables only
|
||||
if (!settings.distributed_group_by_no_merge)
|
||||
optimizeDuplicateDistinct(*select_query);
|
||||
}
|
||||
|
||||
/// Remove functions from ORDER BY if its argument is also in ORDER BY
|
||||
|
@ -31,7 +31,7 @@ ORDER BY number ASC
|
||||
SELECT number
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
SELECT number
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number % 2 AS number
|
||||
|
@ -1,2 +1,4 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
@ -1,4 +1,6 @@
|
||||
set optimize_duplicate_order_by_and_distinct = 1;
|
||||
SET distributed_group_by_no_merge = 0;
|
||||
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
(
|
||||
@ -8,6 +10,30 @@ FROM
|
||||
SETTINGS distributed_group_by_no_merge = 1
|
||||
);
|
||||
|
||||
SET distributed_group_by_no_merge = 1;
|
||||
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM remote('127.0.0.{1,2}', system.numbers)
|
||||
LIMIT 1
|
||||
);
|
||||
|
||||
set optimize_duplicate_order_by_and_distinct = 0;
|
||||
SET distributed_group_by_no_merge = 0;
|
||||
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM remote('127.0.0.{1,2}', system.numbers)
|
||||
LIMIT 1
|
||||
SETTINGS distributed_group_by_no_merge = 1
|
||||
);
|
||||
|
||||
SET distributed_group_by_no_merge = 1;
|
||||
|
||||
set optimize_duplicate_order_by_and_distinct = 0;
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
@ -15,6 +41,4 @@ FROM
|
||||
SELECT DISTINCT number
|
||||
FROM remote('127.0.0.{1,2}', system.numbers)
|
||||
LIMIT 1
|
||||
SETTINGS distributed_group_by_no_merge = 1
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user