Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/12146#discussion_r59093944
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
@@ -176,12 +176,70 @@ case class DescribeDatabase(
}
/**
+ * Drops a table/view from the metastore and removes it if it is cached.
+ *
+ * The syntax of this command is:
+ * {{{
+ * DROP TABLE [IF EXISTS] table_name [PURGE] [FOR REPLICATION(event_id)];
+ * DROP VIEW [IF EXISTS] [db_name.]view_name;
+ * }}}
+ *
+ * Note, PURGE and replication clauses are not supported
+ */
+case class DropTable(
+ tableName: TableIdentifier,
+ ifExists: Boolean,
+ isView: Boolean) extends RunnableCommand {
+
+ override def run(sqlContext: SQLContext): Seq[Row] = {
+ val catalog = sqlContext.sessionState.catalog
+ if (isView && !catalog.isViewSupported) {
+ throw new AnalysisException(s"Not supported object: views")
+ }
+ // If the command DROP VIEW is to drop a table or DROP TABLE is to
drop a view
+ // issue an exception.
+ catalog.getTableOption(tableName).map(_.tableType match {
+ case CatalogTableType.VIRTUAL_VIEW if !isView =>
+ throw new AnalysisException(s"Cannot drop a view with DROP TABLE")
--- End diff --
Sure, will do. Thanks!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]