mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Fix CTE in INSERT-SELECT
This commit is contained in:
parent
be27578294
commit
46f2b4063f
@ -294,7 +294,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(
|
||||
}
|
||||
|
||||
// Only propagate WITH elements to subqueries if we're not a subquery
|
||||
if (options.subquery_depth == 0)
|
||||
if (!options.is_subquery)
|
||||
{
|
||||
if (context->getSettingsRef().enable_global_with_statement)
|
||||
ApplyWithAliasVisitor().visit(query_ptr);
|
||||
|
@ -33,6 +33,7 @@ struct SelectQueryOptions
|
||||
bool ignore_quota = false;
|
||||
bool ignore_limits = false;
|
||||
bool is_internal = false;
|
||||
bool is_subquery = false; // non-subquery can also have subquery_depth > 0, e.g. insert select
|
||||
|
||||
SelectQueryOptions(QueryProcessingStage::Enum stage = QueryProcessingStage::Complete, size_t depth = 0)
|
||||
: to_stage(stage), subquery_depth(depth)
|
||||
@ -46,6 +47,7 @@ struct SelectQueryOptions
|
||||
SelectQueryOptions out = *this;
|
||||
out.to_stage = QueryProcessingStage::Complete;
|
||||
++out.subquery_depth;
|
||||
out.is_subquery = true;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
2
tests/queries/0_stateless/01711_cte_subquery_fix.sql
Normal file
2
tests/queries/0_stateless/01711_cte_subquery_fix.sql
Normal file
@ -0,0 +1,2 @@
|
||||
create or replace table t engine = Memory as with cte as (select * from numbers(10)) select * from cte;
|
||||
drop table t;
|
Loading…
Reference in New Issue
Block a user