Common Table Expressions¶
Common Table Expressions (CTEs) are defined using the WITH clause:
WITH namedQuery (',' namedQuery)* namedQuery : name (columnAliases)? AS? '(' query ')' ;
CTEs allow for statement scoped views that a user can reference (possibly multiple times) within the scope of a SQL statement.
- Common Table Expression (CTE) by the offical Spark documentation
- Common table expression by Wikipedia
- with — Organize Complex Queries