Combines the result of two or more SELECT clauses into a stream or window.
{select_clause} UNION {select_clause} [ UNION ...]
select_clause | A SELECT clause. |
The union operation may produce a stream, delta stream, or a window.
CREATE SCHEMA MySchema (a0 integer, a1 STRING, a2 string); CREATE SCHEMA MySchema2 (a0 integer, a1 STRING, a2 string); CREATE INPUT STREAM InputStream1 SCHEMA MySchema; CREATE INPUT STREAM InputStream2 SCHEMA MySchema2; CREATE INPUT STREAM InputStream3 SCHEMA MySchema2; CREATE OUTPUT STREAM UnionStream1 AS SELECT * FROM InputStream1 UNION SELECT * FROM InputStream2;
CREATE OUTPUT WINDOW UnionWindow1 PRIMARY KEY DEDUCED AS SELECT in1.a0, min(in1.a1) a1, min(in1.a2) a2 FROM InputStream1 in1 GROUP BY in1.a0 UNION SELECT in2.a0, min(in2.a1) a1, min(in2.a2) a2 FROM InputStream2 in2 GROUP BY in2.a0;
CREATE DELTA STREAM Union1 PRIMARY KEY DEDUCED AS SELECT * FROM Stream1 UNION SELECT a.col1, a.col2, a.col3 FROM DeltaStream1 a WHERE a.col1 > 10 UNION SELECT a.a, sum(a.b), max(a.c) FROM Window2 GROUP BY a.a