mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Allow WITH subqueries to take effect immediately
This commit is contained in:
parent
30325689c4
commit
2a747ce5af
@ -16,10 +16,9 @@ void ApplyWithSubqueryVisitor::visit(ASTPtr & ast, const Data & data)
|
||||
std::optional<Data> new_data;
|
||||
if (auto with = node_select->with())
|
||||
{
|
||||
for (auto & child : with->children)
|
||||
visit(child, data);
|
||||
for (auto & child : with->children)
|
||||
{
|
||||
visit(child, new_data ? *new_data: data);
|
||||
if (auto * ast_with_elem = child->as<ASTWithElement>())
|
||||
{
|
||||
if (!new_data)
|
||||
|
@ -30,3 +30,4 @@
|
||||
\N
|
||||
42
|
||||
42
|
||||
1764
|
||||
|
@ -70,4 +70,10 @@ SELECT max(n) m FROM test1 where test1.m=43 having max(n)=42;
|
||||
WITH test1 AS (SELECT n, null b, n+1 m FROM with_test where n = 42 order by n limit 4)
|
||||
SELECT max(n) m FROM test1 where b is null and test1.m=43 having m=42 limit 4;
|
||||
|
||||
with
|
||||
test1 as (select n, null b, n+1 m from with_test where n = 42 order by n limit 4),
|
||||
test2 as (select n + 1 as x, n - 1 as y from test1),
|
||||
test3 as (select x * y as z from test2)
|
||||
select z + 1 as q from test3;
|
||||
|
||||
drop table with_test ;
|
||||
|
Loading…
Reference in New Issue
Block a user