diff --git a/test/sql/cte/materialized/test_cte_in_cte_materialized.test b/test/sql/cte/materialized/test_cte_in_cte_materialized.test index c9fe0f5ac7b..13fecba648f 100644 --- a/test/sql/cte/materialized/test_cte_in_cte_materialized.test +++ b/test/sql/cte/materialized/test_cte_in_cte_materialized.test @@ -48,13 +48,14 @@ with cte1 as MATERIALIZED (Select i as j from a) select * from cte1 where j = (w ---- 42 +require noalternativeverify + +# same name, both get materialized with ALTERNATIVE_VERIFY, so we need 'noalternativeverify' query I with cte as materialized (Select i as j from a) select * from cte where j = (with cte as (select max(j) as j from cte) select j from cte); ---- 42 -require no_alternative_verify - # refer to same-named CTE in a subquery expression statement error with cte as MATERIALIZED (Select i as j from a) select * from cte where j = (with cte as MATERIALIZED (select max(j) as j from cte) select j from cte); diff --git a/test/sql/cte/test_cte.test b/test/sql/cte/test_cte.test index e378610acaa..fd7fc2fd3f0 100644 --- a/test/sql/cte/test_cte.test +++ b/test/sql/cte/test_cte.test @@ -47,12 +47,6 @@ statement error with cte1 as (select 42), cte1 as (select 42) select * FROM cte1; ---- -# reference to CTE before its actually defined -query I -with cte3 as (select ref2.j as i from cte1 as ref2), cte1 as (Select i as j from a), cte2 as (select ref.j+1 as k from cte1 as ref) select * from cte2 union all select * FROM cte3; ----- -43 -42 # multiple uses of same CTE query II @@ -177,29 +171,40 @@ WITH RECURSIVE t(b) AS MATERIALIZED ( (WITH helper(c) AS ( SELECT 5 - ) - SELECT * FROM helper h + ), h1 AS + (SELECT * FROM helper h UNION - SELECT 7 - ) + SELECT 7 FROM helper h) + SELECT * FROM h1) ) SELECT * FROM t ORDER BY b; ---- 5 7 +require noalternativeverify + +# FIXME: this one should work with ALTERNATIVE_VERIFY, but doesn't yet +# something wrong with binding a CTE inside a recursive CTE query I WITH RECURSIVE t(b) AS MATERIALIZED ( (WITH helper(c) AS ( SELECT 5 - ), h1 AS - (SELECT * FROM helper h + ) + SELECT * FROM helper h UNION - SELECT 7 FROM helper h) - SELECT * FROM h1) + SELECT 7 + ) ) SELECT * FROM t ORDER BY b; ---- 5 -7 \ No newline at end of file +7 + +# reference to CTE before its actually defined, can't with ALTERNATIVE_VERIFY because everything gets materialized +query I +with cte3 as (select ref2.j as i from cte1 as ref2), cte1 as (Select i as j from a), cte2 as (select ref.j+1 as k from cte1 as ref) select * from cte2 union all select * FROM cte3; +---- +43 +42 \ No newline at end of file diff --git a/test/sql/cte/test_issue_5673.test b/test/sql/cte/test_issue_5673.test index 9304a783ae2..ea809301365 100644 --- a/test/sql/cte/test_issue_5673.test +++ b/test/sql/cte/test_issue_5673.test @@ -17,11 +17,11 @@ insert into orders values (1); statement ok insert into stg_orders values (1); -statement error +query I with orders as ( - select * from stg_orders - where ordered_at >= (select max(ordered_at) from orders) + select * from main.stg_orders + where ordered_at >= (select max(ordered_at) from main.orders) ), some_more_logic as ( select * @@ -29,13 +29,16 @@ some_more_logic as ( ) select * from some_more_logic; ---- -Binder Error: Circular reference to CTE "orders", There are two possible solutions. +1 -query I +require noalternativeverify + +# this one needs 'noalternativeverify' otherwise the error message is different +statement error with orders as ( - select * from main.stg_orders - where ordered_at >= (select max(ordered_at) from main.orders) + select * from stg_orders + where ordered_at >= (select max(ordered_at) from orders) ), some_more_logic as ( select * @@ -43,4 +46,4 @@ some_more_logic as ( ) select * from some_more_logic; ---- -1 +Binder Error: Circular reference to CTE "orders", There are two possible solutions.