Does Hive support multiple CTEs inside VIEW statement? I know Hive supports CTE (HIVE-1180), but not sure if it has any limitation - for example, supporting multiple CTEs inside VIEW statement:
CREATE OR REPLACE VIEW prdviews.temp
AS WITH set1 AS (SELECT 1 AS id FROM testdb.table1),
set2 AS (select 2 AS id FROM testdb.table2)
SELECT * FROM set1
UNION ALL
SELECT * FROM set2;
select * from prdviews.temp;
Executing above query creates Hive view successfully. But when I run a SELECT query, it returns error. Or am I doing it wrong? The above query or any similar query returns error similar to this:
Error while compiling statement: FAILED: SemanticException Line 3:24 Table not found 'set1' in definition of VIEW temp [ WITH set1 AS (SELECT 1 AS `id` FROM `testdb`.`table1`), set2 AS (select 2 AS `id` FROM `testdb`.`table2`) SELECT `set1`.`id` FROM set1 UNION ALL SELECT `set2`.`id` FROM set2 ] used as temp at Line 1:14
UNION ALL- David דודו Markovitz