Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ case class CreateViewCommand(
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")
s"referencing a temporary view $ident. " +
"Please create a temp view instead by CREATE TEMP VIEW")
case other if !other.resolved => other.expressions.flatMap(_.collect {
// Traverse subquery plan for any unresolved relations.
case e: SubqueryExpression => verify(e.plan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ CREATE VIEW v1_temp AS SELECT * FROM temp_table
struct<>
-- !query 27 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `v1_temp` by referencing a temporary view `temp_table`;
Not allowed to create a permanent view `v1_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 28
Expand Down Expand Up @@ -323,7 +323,7 @@ CREATE VIEW temp_view_test.v3_temp AS SELECT * FROM temp_table
struct<>
-- !query 32 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `temp_view_test`.`v3_temp` by referencing a temporary view `temp_table`;
Not allowed to create a permanent view `temp_view_test`.`v3_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 33
Expand Down Expand Up @@ -372,7 +372,7 @@ CREATE VIEW v4_temp AS
struct<>
-- !query 35 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `v4_temp` by referencing a temporary view `temp_table`;
Not allowed to create a permanent view `v4_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 36
Expand All @@ -384,7 +384,7 @@ CREATE VIEW v5_temp AS
struct<>
-- !query 36 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `v5_temp` by referencing a temporary view `temp_table`;
Not allowed to create a permanent view `v5_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 37
Expand Down Expand Up @@ -543,7 +543,7 @@ CREATE VIEW v6_temp AS SELECT * FROM base_table WHERE id IN (SELECT id FROM temp
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`;
Not allowed to create a permanent view `v6_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 48
Expand All @@ -552,7 +552,7 @@ CREATE VIEW v7_temp AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM tem
struct<>
-- !query 48 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `v7_temp` by referencing a temporary view `temp_table`;
Not allowed to create a permanent view `v7_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 49
Expand All @@ -561,7 +561,7 @@ CREATE VIEW v8_temp AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM temp
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`;
Not allowed to create a permanent view `v8_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 50
Expand All @@ -570,7 +570,7 @@ CREATE VIEW v9_temp AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM
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`;
Not allowed to create a permanent view `v9_temp` by referencing a temporary view `temp_table`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 51
Expand Down Expand Up @@ -679,7 +679,7 @@ CREATE VIEW temporal1 AS SELECT * FROM t1 CROSS JOIN tt
struct<>
-- !query 61 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `temporal1` by referencing a temporary view `tt`;
Not allowed to create a permanent view `temporal1` by referencing a temporary view `tt`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 62
Expand Down Expand Up @@ -720,7 +720,7 @@ CREATE VIEW temporal2 AS SELECT * FROM t1 INNER JOIN tt ON t1.num = tt.num2
struct<>
-- !query 64 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `temporal2` by referencing a temporary view `tt`;
Not allowed to create a permanent view `temporal2` by referencing a temporary view `tt`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 65
Expand Down Expand Up @@ -761,7 +761,7 @@ CREATE VIEW temporal3 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2
struct<>
-- !query 67 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `temporal3` by referencing a temporary view `tt`;
Not allowed to create a permanent view `temporal3` by referencing a temporary view `tt`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 68
Expand Down Expand Up @@ -802,7 +802,7 @@ CREATE VIEW temporal4 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 AND t
struct<>
-- !query 70 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `temporal4` by referencing a temporary view `tt`;
Not allowed to create a permanent view `temporal4` by referencing a temporary view `tt`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 71
Expand All @@ -811,7 +811,7 @@ CREATE VIEW temporal5 AS SELECT * FROM t1 WHERE num IN (SELECT num FROM t1 WHERE
struct<>
-- !query 71 output
org.apache.spark.sql.AnalysisException
Not allowed to create a permanent view `temporal5` by referencing a temporary view `tt`;
Not allowed to create a permanent view `temporal5` by referencing a temporary view `tt`. Please create a temp view instead by CREATE TEMP VIEW;


-- !query 72
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
sql("CREATE VIEW jtv1 AS SELECT * FROM temp_jtv1 WHERE id < 6")
}.getMessage
assert(e.contains("Not allowed to create a permanent view `jtv1` by " +
"referencing a temporary view `temp_jtv1`"))
"referencing a temporary view `temp_jtv1`. " +
"Please create a temp view instead by CREATE TEMP VIEW"))

val globalTempDB = spark.sharedState.globalTempViewManager.database
sql("CREATE GLOBAL TEMP VIEW global_temp_jtv1 AS SELECT * FROM jt WHERE id > 0")
Expand Down