Skip to content

Commit

Permalink
Merge pull request ClickHouse#69676 from ClickHouse/hanfei/fix-create…
Browse files Browse the repository at this point in the history
…-as-with-recursive

fix bug about `CREATE ... AS WITH RECURSIVE`
  • Loading branch information
hanfei1991 authored Oct 1, 2024
2 parents 963d3f4 + 1661f99 commit 5257422
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Interpreters/AddDefaultDatabaseVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ class AddDefaultDatabaseVisitor
{
if (select.recursive_with)
for (const auto & child : select.with()->children)
with_aliases.insert(child->as<ASTWithElement>()->name);
{
if (typeid_cast<ASTWithElement *>(child.get()))
with_aliases.insert(child->as<ASTWithElement>()->name);
}

if (select.tables())
tryVisit<ASTTablesInSelectQuery>(select.refTables());
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
drop table if exists t;
SET enable_analyzer = 1;
create table t1 (a Int64, s DateTime('Asia/Istanbul')) Engine = MergeTree() ORDER BY a;
create view t AS (
WITH RECURSIVE 42 as ttt,
toDate(s) as start_date,
_table as (select 1 as number union all select number + 1 from _table where number < 10)
SELECT a, ttt from t1 join _table on t1.a = _table.number and start_date = '2024-09-23'
);
drop table t;

0 comments on commit 5257422

Please sign in to comment.