v.21.6Improvement
Allow CTE in VIEW Definition
Allow to use CTE in VIEW definition. This closes #22491. #22657 (Amos Bird).
Why it matters
This feature enables users to write more readable and modular VIEW definitions by incorporating CTEs, which simplifies complex queries and enhances query organization within VIEWs.How to use it
When defining a VIEW, include the CTE using theWITH clause inside the VIEW's SELECT statement, just as in regular queries. For example:CREATE VIEW example_view AS
WITH cte_name AS (
SELECT ...
)
SELECT * FROM cte_name;