mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Add global counter to subqueries
This commit is contained in:
parent
7449c25556
commit
dcc8ca49d7
@ -72,13 +72,12 @@ void QueryAliasesVisitor::getNodeAlias(const ASTPtr & ast, Aliases & aliases, co
|
|||||||
|
|
||||||
if (subquery->alias.empty())
|
if (subquery->alias.empty())
|
||||||
{
|
{
|
||||||
size_t subquery_index = 1;
|
static std::atomic_uint64_t subquery_index = 1;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
alias = "_subquery" + toString(subquery_index);
|
alias = "_subquery" + std::to_string(subquery_index++);
|
||||||
if (!aliases.count("_subquery" + toString(subquery_index)))
|
if (!aliases.count(alias))
|
||||||
break;
|
break;
|
||||||
++subquery_index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subquery->setAlias(alias);
|
subquery->setAlias(alias);
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
1
|
||||||
|
0
|
@ -0,0 +1,23 @@
|
|||||||
|
SET compile_expressions = 1;
|
||||||
|
SET min_count_to_compile = 1;
|
||||||
|
SET optimize_move_to_prewhere = 0;
|
||||||
|
SET enable_optimize_predicate_expression=0;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS test.dt;
|
||||||
|
DROP TABLE IF EXISTS test.testx;
|
||||||
|
|
||||||
|
CREATE TABLE test.dt(tkey Int32) ENGINE = MergeTree order by tuple();
|
||||||
|
INSERT INTO test.dt VALUES (300000);
|
||||||
|
CREATE TABLE test.testx(t Int32, a UInt8) ENGINE = MergeTree ORDER BY tuple();
|
||||||
|
INSERT INTO test.testx VALUES (100000, 0);
|
||||||
|
|
||||||
|
SELECT COUNT(*) FROM test.testx WHERE NOT a AND t < (SELECT tkey FROM test.dt);
|
||||||
|
|
||||||
|
DROP TABLE test.dt;
|
||||||
|
CREATE TABLE test.dt(tkey Int32) ENGINE = MergeTree order by tuple();
|
||||||
|
INSERT INTO test.dt VALUES (0);
|
||||||
|
|
||||||
|
SELECT COUNT(*) FROM test.testx WHERE NOT a AND t < (SELECT tkey FROM test.dt);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS test.dt;
|
||||||
|
DROP TABLE IF EXISTS test.testx;
|
Loading…
Reference in New Issue
Block a user