diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala index b31514827220..2440c9bf07cd 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala @@ -190,21 +190,26 @@ case class CreateViewCommand( // added/generated from a temporary view. // 2) The temp functions are represented by multiple classes. Most are inaccessible from this // package (e.g., HiveGenericUDF). - child.collect { - // Disallow creating permanent views based on temporary views. - case UnresolvedRelation(AsTableIdentifier(ident)) + def verify(child: LogicalPlan) { + child.collect { + // Disallow creating permanent views based on temporary views. + case UnresolvedRelation(AsTableIdentifier(ident)) if sparkSession.sessionState.catalog.isTemporaryTable(ident) => - // temporary views are only stored in the session catalog - throw new AnalysisException(s"Not allowed to create a permanent view $name by " + - s"referencing a temporary view $ident") - case other if !other.resolved => other.expressions.flatMap(_.collect { - // Disallow creating permanent views based on temporary UDFs. - case e: UnresolvedFunction - if sparkSession.sessionState.catalog.isTemporaryFunction(e.name) => + // temporary views are only stored in the session catalog throw new AnalysisException(s"Not allowed to create a permanent view $name by " + - s"referencing a temporary function `${e.name}`") - }) + s"referencing a temporary view $ident") + case other if !other.resolved => other.expressions.flatMap(_.collect { + // Traverse subquery plan for any unresolved relations. + case e: SubqueryExpression => verify(e.plan) + // Disallow creating permanent views based on temporary UDFs. + case e: UnresolvedFunction + if sparkSession.sessionState.catalog.isTemporaryFunction(e.name) => + throw new AnalysisException(s"Not allowed to create a permanent view $name by " + + s"referencing a temporary function `${e.name}`") + }) + } } + verify(child) } } diff --git a/sql/core/src/test/resources/sql-tests/inputs/postgreSQL/create_view.sql b/sql/core/src/test/resources/sql-tests/inputs/postgreSQL/create_view.sql index f31097e65648..39e708478e29 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/postgreSQL/create_view.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/postgreSQL/create_view.sql @@ -177,7 +177,6 @@ DESC TABLE EXTENDED v8; -- [SPARK-29628] Forcibly create a temporary view in CREATE VIEW if referencing a temporary view CREATE VIEW v6_temp AS SELECT * FROM base_table WHERE id IN (SELECT id FROM temp_table); CREATE VIEW v7_temp AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM temp_table) t2; --- [SPARK-29630] Not allowed to create a permanent view by referencing a temporary view in EXISTS CREATE VIEW v8_temp AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM temp_table); CREATE VIEW v9_temp AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM temp_table); @@ -232,6 +231,7 @@ CREATE VIEW nontemp4 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2 AND t2 DESC TABLE EXTENDED nontemp4; -- [SPARK-29628] Forcibly create a temporary view in CREATE VIEW if referencing a temporary view CREATE VIEW temporal4 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 AND tt.value = 'xxx'; +CREATE VIEW temporal5 AS SELECT * FROM t1 WHERE num IN (SELECT num FROM t1 WHERE EXISTS (SELECT 1 FROM tt)); -- Skip the tests below because of PostgreSQL specific cases -- SELECT relname FROM pg_class @@ -247,10 +247,10 @@ CREATE TABLE tbl1 ( a int, b int) using parquet; CREATE TABLE tbl2 (c int, d int) using parquet; CREATE TABLE tbl3 (e int, f int) using parquet; CREATE TABLE tbl4 (g int, h int) using parquet; --- Since Spark doesn't support CREATE TEMPORARY TABLE, we used CREATE TEMPORARY VIEW instead +-- Since Spark doesn't support CREATE TEMPORARY TABLE, we used CREATE TABLE instead -- CREATE TEMP TABLE tmptbl (i int, j int); -CREATE TEMP VIEW tmptbl AS SELECT * FROM VALUES - (1, 1) AS temptbl(i, j); +CREATE TABLE tmptbl (i int, j int) using parquet; +INSERT INTO tmptbl VALUES (1, 1); --Should be in testviewschm2 CREATE VIEW pubview AS SELECT * FROM tbl1 WHERE tbl1.a diff --git a/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out b/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out index 9140dd6ca51b..031918961df4 100644 --- a/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 193 +-- Number of queries: 195 -- !query 0 @@ -542,7 +542,8 @@ CREATE VIEW v6_temp AS SELECT * FROM base_table WHERE id IN (SELECT id FROM temp -- !query 47 schema struct<> -- !query 47 output - +org.apache.spark.sql.AnalysisException +Not allowed to create a permanent view `v6_temp` by referencing a temporary view `temp_table`; -- !query 48 @@ -559,7 +560,8 @@ CREATE VIEW v8_temp AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM temp -- !query 49 schema struct<> -- !query 49 output - +org.apache.spark.sql.AnalysisException +Not allowed to create a permanent view `v8_temp` by referencing a temporary view `temp_table`; -- !query 50 @@ -567,7 +569,8 @@ CREATE VIEW v9_temp AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM -- !query 50 schema struct<> -- !query 50 output - +org.apache.spark.sql.AnalysisException +Not allowed to create a permanent view `v9_temp` by referencing a temporary view `temp_table`; -- !query 51 @@ -803,15 +806,16 @@ Not allowed to create a permanent view `temporal4` by referencing a temporary vi -- !query 71 -CREATE TABLE tbl1 ( a int, b int) using parquet +CREATE VIEW temporal5 AS SELECT * FROM t1 WHERE num IN (SELECT num FROM t1 WHERE EXISTS (SELECT 1 FROM tt)) -- !query 71 schema struct<> -- !query 71 output - +org.apache.spark.sql.AnalysisException +Not allowed to create a permanent view `temporal5` by referencing a temporary view `tt`; -- !query 72 -CREATE TABLE tbl2 (c int, d int) using parquet +CREATE TABLE tbl1 ( a int, b int) using parquet -- !query 72 schema struct<> -- !query 72 output @@ -819,7 +823,7 @@ struct<> -- !query 73 -CREATE TABLE tbl3 (e int, f int) using parquet +CREATE TABLE tbl2 (c int, d int) using parquet -- !query 73 schema struct<> -- !query 73 output @@ -827,7 +831,7 @@ struct<> -- !query 74 -CREATE TABLE tbl4 (g int, h int) using parquet +CREATE TABLE tbl3 (e int, f int) using parquet -- !query 74 schema struct<> -- !query 74 output @@ -835,8 +839,7 @@ struct<> -- !query 75 -CREATE TEMP VIEW tmptbl AS SELECT * FROM VALUES - (1, 1) AS temptbl(i, j) +CREATE TABLE tbl4 (g int, h int) using parquet -- !query 75 schema struct<> -- !query 75 output @@ -844,9 +847,7 @@ struct<> -- !query 76 -CREATE VIEW pubview AS SELECT * FROM tbl1 WHERE tbl1.a -BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2) -AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f) +CREATE TABLE tmptbl (i int, j int) using parquet -- !query 76 schema struct<> -- !query 76 output @@ -854,10 +855,28 @@ struct<> -- !query 77 -DESC TABLE EXTENDED pubview +INSERT INTO tmptbl VALUES (1, 1) -- !query 77 schema -struct +struct<> -- !query 77 output + + + +-- !query 78 +CREATE VIEW pubview AS SELECT * FROM tbl1 WHERE tbl1.a +BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2) +AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f) +-- !query 78 schema +struct<> +-- !query 78 output + + + +-- !query 79 +DESC TABLE EXTENDED pubview +-- !query 79 schema +struct +-- !query 79 output a int b int @@ -879,22 +898,22 @@ View Query Output Columns [a, b] Table Properties [view.default.database=testviewschm2, view.query.out.col.1=b, view.query.out.col.0=a, view.query.out.numCols=2] --- !query 78 +-- !query 80 CREATE VIEW mytempview AS SELECT * FROM tbl1 WHERE tbl1.a BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2) AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f) AND NOT EXISTS (SELECT g FROM tbl4 LEFT JOIN tmptbl ON tbl4.h = tmptbl.j) --- !query 78 schema +-- !query 80 schema struct<> --- !query 78 output +-- !query 80 output --- !query 79 +-- !query 81 DESC TABLE EXTENDED mytempview --- !query 79 schema +-- !query 81 schema struct --- !query 79 output +-- !query 81 output a int b int @@ -918,55 +937,39 @@ View Query Output Columns [a, b] Table Properties [view.default.database=testviewschm2, view.query.out.col.1=b, view.query.out.col.0=a, view.query.out.numCols=2] --- !query 80 +-- !query 82 CREATE VIEW tt1 AS SELECT * FROM ( VALUES ('abc', '0123456789', 42, 'abcd'), ('0123456789', 'abc', 42.12, 'abc') ) vv(a,b,c,d) --- !query 80 schema +-- !query 82 schema struct<> --- !query 80 output +-- !query 82 output --- !query 81 +-- !query 83 SELECT * FROM tt1 --- !query 81 schema +-- !query 83 schema struct --- !query 81 output +-- !query 83 output 0123456789 abc 42.12 abc abc 0123456789 42 abcd --- !query 82 +-- !query 84 SELECT string(a) FROM tt1 --- !query 82 schema +-- !query 84 schema struct --- !query 82 output +-- !query 84 output 0123456789 abc --- !query 83 -DROP VIEW tt1 --- !query 83 schema -struct<> --- !query 83 output - - - --- !query 84 -CREATE TABLE tt1 (f1 int, f2 int, f3 string) using parquet --- !query 84 schema -struct<> --- !query 84 output - - - -- !query 85 -CREATE TABLE tx1 (x1 int, x2 int, x3 string) using parquet +DROP VIEW tt1 -- !query 85 schema struct<> -- !query 85 output @@ -974,7 +977,7 @@ struct<> -- !query 86 -CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 string) using parquet +CREATE TABLE tt1 (f1 int, f2 int, f3 string) using parquet -- !query 86 schema struct<> -- !query 86 output @@ -982,9 +985,7 @@ struct<> -- !query 87 -CREATE VIEW aliased_view_1 AS - select * from tt1 - where exists (select 1 from tx1 where tt1.f1 = tx1.x1) +CREATE TABLE tx1 (x1 int, x2 int, x3 string) using parquet -- !query 87 schema struct<> -- !query 87 output @@ -992,9 +993,7 @@ struct<> -- !query 88 -CREATE VIEW aliased_view_2 AS - select * from tt1 a1 - where exists (select 1 from tx1 where a1.f1 = tx1.x1) +CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 string) using parquet -- !query 88 schema struct<> -- !query 88 output @@ -1002,9 +1001,9 @@ struct<> -- !query 89 -CREATE VIEW aliased_view_3 AS +CREATE VIEW aliased_view_1 AS select * from tt1 - where exists (select 1 from tx1 a2 where tt1.f1 = a2.x1) + where exists (select 1 from tx1 where tt1.f1 = tx1.x1) -- !query 89 schema struct<> -- !query 89 output @@ -1012,9 +1011,9 @@ struct<> -- !query 90 -CREATE VIEW aliased_view_4 AS - select * from temp_view_test.tt1 - where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1) +CREATE VIEW aliased_view_2 AS + select * from tt1 a1 + where exists (select 1 from tx1 where a1.f1 = tx1.x1) -- !query 90 schema struct<> -- !query 90 output @@ -1022,27 +1021,27 @@ struct<> -- !query 91 -DESC TABLE aliased_view_1 +CREATE VIEW aliased_view_3 AS + select * from tt1 + where exists (select 1 from tx1 a2 where tt1.f1 = a2.x1) -- !query 91 schema -struct +struct<> -- !query 91 output -f1 int -f2 int -f3 string + -- !query 92 -DESC TABLE aliased_view_2 +CREATE VIEW aliased_view_4 AS + select * from temp_view_test.tt1 + where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1) -- !query 92 schema -struct +struct<> -- !query 92 output -f1 int -f2 int -f3 string + -- !query 93 -DESC TABLE aliased_view_3 +DESC TABLE aliased_view_1 -- !query 93 schema struct -- !query 93 output @@ -1052,45 +1051,45 @@ f3 string -- !query 94 -DESC TABLE aliased_view_4 +DESC TABLE aliased_view_2 -- !query 94 schema struct -- !query 94 output -y1 int +f1 int f2 int f3 string -- !query 95 -ALTER TABLE tx1 RENAME TO a1 +DESC TABLE aliased_view_3 -- !query 95 schema -struct<> +struct -- !query 95 output - +f1 int +f2 int +f3 string -- !query 96 -DESC TABLE aliased_view_1 +DESC TABLE aliased_view_4 -- !query 96 schema struct -- !query 96 output -f1 int +y1 int f2 int f3 string -- !query 97 -DESC TABLE aliased_view_2 +ALTER TABLE tx1 RENAME TO a1 -- !query 97 schema -struct +struct<> -- !query 97 output -f1 int -f2 int -f3 string + -- !query 98 -DESC TABLE aliased_view_3 +DESC TABLE aliased_view_1 -- !query 98 schema struct -- !query 98 output @@ -1100,45 +1099,45 @@ f3 string -- !query 99 -DESC TABLE aliased_view_4 +DESC TABLE aliased_view_2 -- !query 99 schema struct -- !query 99 output -y1 int +f1 int f2 int f3 string -- !query 100 -ALTER TABLE tt1 RENAME TO a2 +DESC TABLE aliased_view_3 -- !query 100 schema -struct<> +struct -- !query 100 output - +f1 int +f2 int +f3 string -- !query 101 -DESC TABLE aliased_view_1 +DESC TABLE aliased_view_4 -- !query 101 schema struct -- !query 101 output -f1 int +y1 int f2 int f3 string -- !query 102 -DESC TABLE aliased_view_2 +ALTER TABLE tt1 RENAME TO a2 -- !query 102 schema -struct +struct<> -- !query 102 output -f1 int -f2 int -f3 string + -- !query 103 -DESC TABLE aliased_view_3 +DESC TABLE aliased_view_1 -- !query 103 schema struct -- !query 103 output @@ -1148,45 +1147,45 @@ f3 string -- !query 104 -DESC TABLE aliased_view_4 +DESC TABLE aliased_view_2 -- !query 104 schema struct -- !query 104 output -y1 int +f1 int f2 int f3 string -- !query 105 -ALTER TABLE a1 RENAME TO tt1 +DESC TABLE aliased_view_3 -- !query 105 schema -struct<> +struct -- !query 105 output - +f1 int +f2 int +f3 string -- !query 106 -DESC TABLE aliased_view_1 +DESC TABLE aliased_view_4 -- !query 106 schema struct -- !query 106 output -f1 int +y1 int f2 int f3 string -- !query 107 -DESC TABLE aliased_view_2 +ALTER TABLE a1 RENAME TO tt1 -- !query 107 schema -struct +struct<> -- !query 107 output -f1 int -f2 int -f3 string + -- !query 108 -DESC TABLE aliased_view_3 +DESC TABLE aliased_view_1 -- !query 108 schema struct -- !query 108 output @@ -1196,36 +1195,37 @@ f3 string -- !query 109 -DESC TABLE aliased_view_4 +DESC TABLE aliased_view_2 -- !query 109 schema struct -- !query 109 output -y1 int +f1 int f2 int f3 string -- !query 110 -ALTER TABLE a2 RENAME TO tx1 +DESC TABLE aliased_view_3 -- !query 110 schema -struct<> +struct -- !query 110 output - +f1 int +f2 int +f3 string -- !query 111 -create view view_of_joins as -select * from - (select * from (tbl1 cross join tbl2) same) ss, - (tbl3 cross join tbl4) same +DESC TABLE aliased_view_4 -- !query 111 schema -struct<> +struct -- !query 111 output - +y1 int +f2 int +f3 string -- !query 112 -create table tt2 (a int, b int, c int) using parquet +ALTER TABLE a2 RENAME TO tx1 -- !query 112 schema struct<> -- !query 112 output @@ -1233,7 +1233,10 @@ struct<> -- !query 113 -create table tt3 (ax bigint, b short, c decimal) using parquet +create view view_of_joins as +select * from + (select * from (tbl1 cross join tbl2) same) ss, + (tbl3 cross join tbl4) same -- !query 113 schema struct<> -- !query 113 output @@ -1241,7 +1244,7 @@ struct<> -- !query 114 -create table tt4 (ay int, b int, q int) using parquet +create table tt2 (a int, b int, c int) using parquet -- !query 114 schema struct<> -- !query 114 output @@ -1249,7 +1252,7 @@ struct<> -- !query 115 -create view v1 as select * from tt2 natural join tt3 +create table tt3 (ax bigint, b short, c decimal) using parquet -- !query 115 schema struct<> -- !query 115 output @@ -1257,7 +1260,7 @@ struct<> -- !query 116 -create view v1a as select * from (tt2 natural join tt3) j +create table tt4 (ay int, b int, q int) using parquet -- !query 116 schema struct<> -- !query 116 output @@ -1265,7 +1268,7 @@ struct<> -- !query 117 -create view v2 as select * from tt2 join tt3 using (b,c) join tt4 using (b) +create view v1 as select * from tt2 natural join tt3 -- !query 117 schema struct<> -- !query 117 output @@ -1273,7 +1276,7 @@ struct<> -- !query 118 -create view v2a as select * from (tt2 join tt3 using (b,c) join tt4 using (b)) j +create view v1a as select * from (tt2 natural join tt3) j -- !query 118 schema struct<> -- !query 118 output @@ -1281,7 +1284,7 @@ struct<> -- !query 119 -create view v3 as select * from tt2 join tt3 using (b,c) full join tt4 using (b) +create view v2 as select * from tt2 join tt3 using (b,c) join tt4 using (b) -- !query 119 schema struct<> -- !query 119 output @@ -1289,32 +1292,48 @@ struct<> -- !query 120 -DESC TABLE v1 +create view v2a as select * from (tt2 join tt3 using (b,c) join tt4 using (b)) j -- !query 120 schema -struct +struct<> -- !query 120 output -b int -c int + + + +-- !query 121 +create view v3 as select * from tt2 join tt3 using (b,c) full join tt4 using (b) +-- !query 121 schema +struct<> +-- !query 121 output + + + +-- !query 122 +DESC TABLE v1 +-- !query 122 schema +struct +-- !query 122 output +b int +c int a int ax bigint --- !query 121 +-- !query 123 DESC TABLE v1a --- !query 121 schema +-- !query 123 schema struct --- !query 121 output +-- !query 123 output b int c int a int ax bigint --- !query 122 +-- !query 124 DESC TABLE v2 --- !query 122 schema +-- !query 124 schema struct --- !query 122 output +-- !query 124 output b int c int a int @@ -1323,11 +1342,11 @@ ay int q int --- !query 123 +-- !query 125 DESC TABLE v2a --- !query 123 schema +-- !query 125 schema struct --- !query 123 output +-- !query 125 output b int c int a int @@ -1336,11 +1355,11 @@ ay int q int --- !query 124 +-- !query 126 DESC TABLE v3 --- !query 124 schema +-- !query 126 schema struct --- !query 124 output +-- !query 126 output b int c int a int @@ -1349,49 +1368,49 @@ ay int q int --- !query 125 +-- !query 127 alter table tt2 add column d int --- !query 125 schema +-- !query 127 schema struct<> --- !query 125 output +-- !query 127 output --- !query 126 +-- !query 128 alter table tt2 add column e int --- !query 126 schema +-- !query 128 schema struct<> --- !query 126 output +-- !query 128 output --- !query 127 +-- !query 129 DESC TABLE v1 --- !query 127 schema +-- !query 129 schema struct --- !query 127 output +-- !query 129 output b int c int a int ax bigint --- !query 128 +-- !query 130 DESC TABLE v1a --- !query 128 schema +-- !query 130 schema struct --- !query 128 output +-- !query 130 output b int c int a int ax bigint --- !query 129 +-- !query 131 DESC TABLE v2 --- !query 129 schema +-- !query 131 schema struct --- !query 129 output +-- !query 131 output b int c int a int @@ -1400,11 +1419,11 @@ ay int q int --- !query 130 +-- !query 132 DESC TABLE v2a --- !query 130 schema +-- !query 132 schema struct --- !query 130 output +-- !query 132 output b int c int a int @@ -1413,11 +1432,11 @@ ay int q int --- !query 131 +-- !query 133 DESC TABLE v3 --- !query 131 schema +-- !query 133 schema struct --- !query 131 output +-- !query 133 output b int c int a int @@ -1426,65 +1445,65 @@ ay int q int --- !query 132 +-- !query 134 drop table tt3 --- !query 132 schema +-- !query 134 schema struct<> --- !query 132 output +-- !query 134 output --- !query 133 +-- !query 135 create table tt3 (ax bigint, b short, d decimal) using parquet --- !query 133 schema +-- !query 135 schema struct<> --- !query 133 output +-- !query 135 output --- !query 134 +-- !query 136 alter table tt3 add column c int --- !query 134 schema +-- !query 136 schema struct<> --- !query 134 output +-- !query 136 output --- !query 135 +-- !query 137 alter table tt3 add column e int --- !query 135 schema +-- !query 137 schema struct<> --- !query 135 output +-- !query 137 output --- !query 136 +-- !query 138 DESC TABLE v1 --- !query 136 schema +-- !query 138 schema struct --- !query 136 output +-- !query 138 output b int c int a int ax bigint --- !query 137 +-- !query 139 DESC TABLE v1a --- !query 137 schema +-- !query 139 schema struct --- !query 137 output +-- !query 139 output b int c int a int ax bigint --- !query 138 +-- !query 140 DESC TABLE v2 --- !query 138 schema +-- !query 140 schema struct --- !query 138 output +-- !query 140 output b int c int a int @@ -1493,11 +1512,11 @@ ay int q int --- !query 139 +-- !query 141 DESC TABLE v2a --- !query 139 schema +-- !query 141 schema struct --- !query 139 output +-- !query 141 output b int c int a int @@ -1506,11 +1525,11 @@ ay int q int --- !query 140 +-- !query 142 DESC TABLE v3 --- !query 140 schema +-- !query 142 schema struct --- !query 140 output +-- !query 142 output b int c int a int @@ -1519,24 +1538,8 @@ ay int q int --- !query 141 -create table tt5 (a int, b int) using parquet --- !query 141 schema -struct<> --- !query 141 output - - - --- !query 142 -create table tt6 (c int, d int) using parquet --- !query 142 schema -struct<> --- !query 142 output - - - -- !query 143 -create view vv1 as select * from (tt5 cross join tt6) j(aa,bb,cc,dd) +create table tt5 (a int, b int) using parquet -- !query 143 schema struct<> -- !query 143 output @@ -1544,18 +1547,15 @@ struct<> -- !query 144 -DESC TABLE vv1 +create table tt6 (c int, d int) using parquet -- !query 144 schema -struct +struct<> -- !query 144 output -aa int -bb int -cc int -dd int + -- !query 145 -alter table tt5 add column c int +create view vv1 as select * from (tt5 cross join tt6) j(aa,bb,cc,dd) -- !query 145 schema struct<> -- !query 145 output @@ -1574,7 +1574,7 @@ dd int -- !query 147 -alter table tt5 add column cc int +alter table tt5 add column c int -- !query 147 schema struct<> -- !query 147 output @@ -1593,7 +1593,7 @@ dd int -- !query 149 -create table tt7 (x int, /* xx int, */ y int) using parquet +alter table tt5 add column cc int -- !query 149 schema struct<> -- !query 149 output @@ -1601,29 +1601,48 @@ struct<> -- !query 150 -create table tt8 (x int, z int) using parquet +DESC TABLE vv1 -- !query 150 schema -struct<> +struct -- !query 150 output - +aa int +bb int +cc int +dd int -- !query 151 +create table tt7 (x int, /* xx int, */ y int) using parquet +-- !query 151 schema +struct<> +-- !query 151 output + + + +-- !query 152 +create table tt8 (x int, z int) using parquet +-- !query 152 schema +struct<> +-- !query 152 output + + + +-- !query 153 create view vv2 as select * from (values(1,2,3,4,5)) v(a,b,c,d,e) union all select * from tt7 full join tt8 using (x), tt8 tt8x --- !query 151 schema +-- !query 153 schema struct<> --- !query 151 output +-- !query 153 output --- !query 152 +-- !query 154 DESC TABLE vv2 --- !query 152 schema +-- !query 154 schema struct --- !query 152 output +-- !query 154 output a int b int c int @@ -1631,24 +1650,24 @@ d int e int --- !query 153 +-- !query 155 create view vv3 as select * from (values(1,2,3,4,5,6)) v(a,b,c,x,e,f) union all select * from tt7 full join tt8 using (x), tt7 tt7x full join tt8 tt8x using (x) --- !query 153 schema +-- !query 155 schema struct<> --- !query 153 output +-- !query 155 output --- !query 154 +-- !query 156 DESC TABLE vv3 --- !query 154 schema +-- !query 156 schema struct --- !query 154 output +-- !query 156 output a int b int c int @@ -1657,24 +1676,24 @@ e int f int --- !query 155 +-- !query 157 create view vv4 as select * from (values(1,2,3,4,5,6,7)) v(a,b,c,x,e,f,g) union all select * from tt7 full join tt8 using (x), tt7 tt7x full join tt8 tt8x using (x) full join tt8 tt8y using (x) --- !query 155 schema +-- !query 157 schema struct<> --- !query 155 output +-- !query 157 output --- !query 156 +-- !query 158 DESC TABLE vv4 --- !query 156 schema +-- !query 158 schema struct --- !query 156 output +-- !query 158 output a int b int c int @@ -1684,35 +1703,35 @@ f int g int --- !query 157 +-- !query 159 alter table tt7 add column zz int --- !query 157 schema +-- !query 159 schema struct<> --- !query 157 output +-- !query 159 output --- !query 158 +-- !query 160 alter table tt7 add column z int --- !query 158 schema +-- !query 160 schema struct<> --- !query 158 output +-- !query 160 output --- !query 159 +-- !query 161 alter table tt8 add column z2 int --- !query 159 schema +-- !query 161 schema struct<> --- !query 159 output +-- !query 161 output --- !query 160 +-- !query 162 DESC TABLE vv2 --- !query 160 schema +-- !query 162 schema struct --- !query 160 output +-- !query 162 output a int b int c int @@ -1720,11 +1739,11 @@ d int e int --- !query 161 +-- !query 163 DESC TABLE vv3 --- !query 161 schema +-- !query 163 schema struct --- !query 161 output +-- !query 163 output a int b int c int @@ -1733,11 +1752,11 @@ e int f int --- !query 162 +-- !query 164 DESC TABLE vv4 --- !query 162 schema +-- !query 164 schema struct --- !query 162 output +-- !query 164 output a int b int c int @@ -1747,38 +1766,38 @@ f int g int --- !query 163 +-- !query 165 create table tt7a (x date, /* xx int, */ y int) using parquet --- !query 163 schema +-- !query 165 schema struct<> --- !query 163 output +-- !query 165 output --- !query 164 +-- !query 166 create table tt8a (x timestamp, z int) using parquet --- !query 164 schema +-- !query 166 schema struct<> --- !query 164 output +-- !query 166 output --- !query 165 +-- !query 167 create view vv2a as select * from (values(now(),2,3,now(),5)) v(a,b,c,d,e) union all select * from tt7a left join tt8a using (x), tt8a tt8ax --- !query 165 schema +-- !query 167 schema struct<> --- !query 165 output +-- !query 167 output --- !query 166 +-- !query 168 DESC TABLE vv4 --- !query 166 schema +-- !query 168 schema struct --- !query 166 output +-- !query 168 output a int b int c int @@ -1788,11 +1807,11 @@ f int g int --- !query 167 +-- !query 169 DESC TABLE vv2a --- !query 167 schema +-- !query 169 schema struct --- !query 167 output +-- !query 169 output a timestamp b int c int @@ -1800,155 +1819,155 @@ d timestamp e int --- !query 168 +-- !query 170 create table tt9 (x int, xx int, y int) using parquet --- !query 168 schema +-- !query 170 schema struct<> --- !query 168 output +-- !query 170 output --- !query 169 +-- !query 171 create table tt10 (x int, z int) using parquet --- !query 169 schema +-- !query 171 schema struct<> --- !query 169 output +-- !query 171 output --- !query 170 +-- !query 172 create view vv5 as select x,y,z from tt9 join tt10 using(x) --- !query 170 schema +-- !query 172 schema struct<> --- !query 170 output +-- !query 172 output --- !query 171 +-- !query 173 DESC TABLE vv5 --- !query 171 schema +-- !query 173 schema struct --- !query 171 output +-- !query 173 output x int y int z int --- !query 172 +-- !query 174 DESC TABLE vv5 --- !query 172 schema +-- !query 174 schema struct --- !query 172 output +-- !query 174 output x int y int z int --- !query 173 +-- !query 175 create table tt11 (x int, y int) using parquet --- !query 173 schema +-- !query 175 schema struct<> --- !query 173 output +-- !query 175 output --- !query 174 +-- !query 176 create table tt12 (x int, z int) using parquet --- !query 174 schema +-- !query 176 schema struct<> --- !query 174 output +-- !query 176 output --- !query 175 +-- !query 177 create table tt13 (z int, q int) using parquet --- !query 175 schema +-- !query 177 schema struct<> --- !query 175 output +-- !query 177 output --- !query 176 +-- !query 178 create view vv6 as select x,y,z,q from (tt11 join tt12 using(x)) join tt13 using(z) --- !query 176 schema +-- !query 178 schema struct<> --- !query 176 output +-- !query 178 output --- !query 177 +-- !query 179 DESC TABLE vv6 --- !query 177 schema +-- !query 179 schema struct --- !query 177 output +-- !query 179 output x int y int z int q int --- !query 178 +-- !query 180 alter table tt11 add column z int --- !query 178 schema +-- !query 180 schema struct<> --- !query 178 output +-- !query 180 output --- !query 179 +-- !query 181 DESC TABLE vv6 --- !query 179 schema +-- !query 181 schema struct --- !query 179 output +-- !query 181 output x int y int z int q int --- !query 180 +-- !query 182 CREATE TABLE int8_tbl (q1 int, q2 int) USING parquet --- !query 180 schema +-- !query 182 schema struct<> --- !query 180 output +-- !query 182 output --- !query 181 +-- !query 183 create view tt18v as select * from int8_tbl xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy union all select * from int8_tbl xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz --- !query 181 schema +-- !query 183 schema struct<> --- !query 181 output +-- !query 183 output --- !query 182 +-- !query 184 DESC TABLE tt18v --- !query 182 schema +-- !query 184 schema struct --- !query 182 output +-- !query 184 output q1 int q2 int --- !query 183 +-- !query 185 create view tt21v as select * from tt5 natural inner join tt6 --- !query 183 schema +-- !query 185 schema struct<> --- !query 183 output +-- !query 185 output --- !query 184 +-- !query 186 DESC TABLE tt21v --- !query 184 schema +-- !query 186 schema struct --- !query 184 output +-- !query 186 output c int a int b int @@ -1956,20 +1975,20 @@ cc int d int --- !query 185 +-- !query 187 create view tt22v as select * from tt5 natural left join tt6 --- !query 185 schema +-- !query 187 schema struct<> --- !query 185 output +-- !query 187 output --- !query 186 +-- !query 188 DESC TABLE tt22v --- !query 186 schema +-- !query 188 schema struct --- !query 186 output +-- !query 188 output c int a int b int @@ -1977,53 +1996,53 @@ cc int d int --- !query 187 +-- !query 189 create view tt23v (col_a, col_b) as select q1 as other_name1, q2 as other_name2 from int8_tbl union select 42, 43 --- !query 187 schema +-- !query 189 schema struct<> --- !query 187 output +-- !query 189 output --- !query 188 +-- !query 190 DESC TABLE tt23v --- !query 188 schema +-- !query 190 schema struct --- !query 188 output +-- !query 190 output col_a int col_b int --- !query 189 +-- !query 191 DROP SCHEMA temp_view_test CASCADE --- !query 189 schema +-- !query 191 schema struct<> --- !query 189 output +-- !query 191 output --- !query 190 +-- !query 192 DROP SCHEMA testviewschm2 CASCADE --- !query 190 schema +-- !query 192 schema struct<> --- !query 190 output +-- !query 192 output --- !query 191 +-- !query 193 DROP VIEW temp_table --- !query 191 schema +-- !query 193 schema struct<> --- !query 191 output +-- !query 193 output --- !query 192 +-- !query 194 DROP VIEW tt --- !query 192 schema +-- !query 194 schema struct<> --- !query 192 output +-- !query 194 output