Back to home page

OSCL-LXR

 
 

    


0001 -- This test file was converted from union.sql.
0002 
0003 CREATE OR REPLACE TEMPORARY VIEW t1 AS VALUES (1, 'a'), (2, 'b') tbl(c1, c2);
0004 CREATE OR REPLACE TEMPORARY VIEW t2 AS VALUES (1.0, 1), (2.0, 4) tbl(c1, c2);
0005 
0006 -- Simple Union
0007 SELECT udf(c1) as c1, udf(c2) as c2
0008 FROM   (SELECT udf(c1) as c1, udf(c2) as c2 FROM t1
0009         UNION ALL
0010         SELECT udf(c1) as c1, udf(c2) as c2 FROM t1);
0011 
0012 -- Type Coerced Union
0013 SELECT udf(c1) as c1, udf(c2) as c2
0014 FROM   (SELECT udf(c1) as c1, udf(c2) as c2 FROM t1
0015         UNION ALL
0016         SELECT udf(c1) as c1, udf(c2) as c2 FROM t2
0017         UNION ALL
0018         SELECT udf(c1) as c1, udf(c2) as c2 FROM t2);
0019 
0020 -- Regression test for SPARK-18622
0021 SELECT udf(udf(a)) as a
0022 FROM (SELECT udf(0) a, udf(0) b
0023       UNION ALL
0024       SELECT udf(SUM(1)) a, udf(CAST(0 AS BIGINT)) b
0025       UNION ALL SELECT udf(0) a, udf(0) b) T;
0026 
0027 -- Regression test for SPARK-18841 Push project through union should not be broken by redundant alias removal.
0028 CREATE OR REPLACE TEMPORARY VIEW p1 AS VALUES 1 T(col);
0029 CREATE OR REPLACE TEMPORARY VIEW p2 AS VALUES 1 T(col);
0030 CREATE OR REPLACE TEMPORARY VIEW p3 AS VALUES 1 T(col);
0031 SELECT udf(1) AS x,
0032        udf(col) as col
0033 FROM   (SELECT udf(col) AS col
0034         FROM (SELECT udf(p1.col) AS col
0035               FROM   p1 CROSS JOIN p2
0036               UNION ALL
0037               SELECT udf(col)
0038               FROM p3) T1) T2;
0039 
0040 -- SPARK-24012 Union of map and other compatible columns.
0041 SELECT map(1, 2), udf('str') as str
0042 UNION ALL
0043 SELECT map(1, 2, 3, NULL), udf(1);
0044 
0045 -- SPARK-24012 Union of array and other compatible columns.
0046 SELECT array(1, 2), udf('str') as str
0047 UNION ALL
0048 SELECT array(1, 2, 3, NULL), udf(1);
0049 
0050 
0051 -- Clean-up
0052 DROP VIEW IF EXISTS t1;
0053 DROP VIEW IF EXISTS t2;
0054 DROP VIEW IF EXISTS p1;
0055 DROP VIEW IF EXISTS p2;
0056 DROP VIEW IF EXISTS p3;