From 68be5b9e8a5ac1fc4d243bb54c2ca95fee3f74dc Mon Sep 17 00:00:00 2001 From: gatorsmile Date: Tue, 5 Apr 2016 22:33:44 -0700 Subject: [SPARK-14396][SQL] Throw Exceptions for DDLs of Partitioned Views #### What changes were proposed in this pull request? Because the concept of partitioning is associated with physical tables, we disable all the supports of partitioned views, which are defined in the following three commands in [Hive DDL Manual](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Create/Drop/AlterView): ``` ALTER VIEW view DROP [IF EXISTS] PARTITION spec1[, PARTITION spec2, ...]; ALTER VIEW view ADD [IF NOT EXISTS] PARTITION spec; CREATE VIEW [IF NOT EXISTS] [db_name.]view_name [(column_name [COMMENT column_comment], ...) ] [COMMENT view_comment] [TBLPROPERTIES (property_name = property_value, ...)] AS SELECT ...; ``` An exception is thrown when users issue any of these three DDL commands. #### How was this patch tested? Added test cases for parsing create view and changed the existing test cases to verify if the exceptions are thrown. Author: gatorsmile Author: xiaoli Author: Xiao Li Closes #12169 from gatorsmile/viewPartition. --- .../org/apache/spark/sql/hive/execution/HiveSqlParser.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sql/hive/src/main') diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveSqlParser.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveSqlParser.scala index c6c0b2ca59..ab69d3502e 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveSqlParser.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveSqlParser.scala @@ -215,11 +215,19 @@ class HiveSqlAstBuilder extends SparkSqlAstBuilder { /** * Create or replace a view. This creates a [[CreateViewAsSelect]] command. + * + * For example: + * {{{ + * CREATE VIEW [IF NOT EXISTS] [db_name.]view_name + * [(column_name [COMMENT column_comment], ...) ] + * [COMMENT view_comment] + * [TBLPROPERTIES (property_name = property_value, ...)] + * AS SELECT ...; + * }}} */ override def visitCreateView(ctx: CreateViewContext): LogicalPlan = withOrigin(ctx) { - // Pass a partitioned view on to hive. if (ctx.identifierList != null) { - HiveNativeCommand(command(ctx)) + throw new ParseException(s"Operation not allowed: partitioned views", ctx) } else { if (ctx.STRING != null) { logWarning("COMMENT clause is ignored.") -- cgit v1.2.3