WITH
a AS (SELECT 1 AS t),
b AS (SELECT 2 AS t)
SELECT * FROM a UNION SELECT * FROM b
WITH
statement is an unsuccessful attempt for SQL to become a language, Fugue SQL has a much better solution for value assignment and reuse. However, we should try to be compatible with the standard SQL on this.
So the compromise will be, if users using WITH
statement, this entire WITH
and SELECT
statement should directly get data from the sql engine (external data source), and can't consume any previous dataframes.
For example, this is ok, because it doesn't consume dataframes
WITH
a AS (SELECT 1 AS t),
b AS (SELECT 2 AS t)
SELECT * FROM a UNION SELECT * FROM b
this is also ok, because the data source is from hive:
WITH
a AS (SELECT * FROM hive.table1),
b AS (SELECT * FROM hive.table2)
SELECT * FROM a UNION SELECT * FROM b
this is also ok, because the data source is from the specified custom sql engine:
CONNECT CustomSQLEngine WITH
a AS (SELECT * FROM t1),
b AS (SELECT * FROM 22)
SELECT * FROM a UNION SELECT * FROM b
this is not ok, because it tries to consume t1
and t2
generated in the previous steps
t1 = CREATE [[0]] SCHEMA a:int
t2 = CREATE [[1]] SCHEMA a:int
WITH
a AS (SELECT * FROM t1),
b AS (SELECT * FROM 22)
SELECT * FROM a UNION SELECT * FROM b