Getting ORA-32042 even though i can create the view in SQL Developer
Interesting. It works without the column alias in the mview definition.

with
  bar as (select * from dual),
  foo(lvl) as
  ( 
    select 1 as lvl from bar
    union all
    select foo.lvl + 1 from foo join bar on (foo.lvl &lt; 5)
  )
select lvl from foo;

       LVL
----------
         1
         2
         3
         4
         5


Create mview fails with column alias in definition:

create materialized view mv1(lvl) as
with
  bar as (select * from dual),
  foo(lvl) as
  ( 
    select 1 as lvl from bar
    union all
    select foo.lvl + 1 from foo join bar on (foo.lvl &lt; 5)
  )
select lvl from foo;

Error report -
ORA-12018: following error encountered during code generation for "BP"."MV1"
ORA-32042: recursive WITH clause must reference itself directly in one of the UNION ALL branches
12018. 0000 -  "following error encountered during code generation for \"%s\".\"%s\""
*Cause:    The refresh operations for the indicated materialized view could
           not be regenerated due to errors.
*Action:   Correct the problem indicated in the following error messages and
           repeat the operation.


But it works without the column alias:

create materialized view mv1 as
with
  bar as (select * from dual),
  foo(lvl) as
  ( 
    select 1 as lvl from bar
    union all
    select foo.lvl + 1 from foo join bar on (foo.lvl &lt; 5)
  )
select lvl from foo;

Materialized view MV1 created.


I see no reason for your version not working, it may be a bug, but I could not find anything related to this on the support site of Oracle.

Above output is from version 18.4.