Skip to content

Conversation

@gatorsmile
Copy link
Member

What changes were proposed in this pull request?

This PR is to provide a native DDL support for the following three Alter View commands:

Based on the Hive DDL document:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL

1. ALTER VIEW RENAME

Syntax:

ALTER VIEW view_name RENAME TO new_view_name
  • to change the name of a view to a different name
  • not allowed to rename a view's name by ALTER TABLE
2. ALTER VIEW SET TBLPROPERTIES

Syntax:

ALTER VIEW view_name SET TBLPROPERTIES ('comment' = new_comment);
  • to add metadata to a view
  • not allowed to set views' properties by ALTER TABLE
  • ignore it if trying to set a view's existing property key when the value is the same
  • overwrite the value if trying to set a view's existing key to a different value
3. ALTER VIEW UNSET TBLPROPERTIES

Syntax:

ALTER VIEW view_name UNSET TBLPROPERTIES [IF EXISTS] ('comment', 'key')
  • to remove metadata from a view
  • not allowed to unset views' properties by ALTER TABLE
  • issue an exception if trying to unset a view's non-existent key

How was this patch tested?

Added test cases to verify if it works properly.

gatorsmile and others added 30 commits November 13, 2015 14:50
@SparkQA
Copy link

SparkQA commented Apr 12, 2016

Test build #55595 has finished for PR 12324 at commit cd20636.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member Author

cc @yhuai @andrewor14

catalog.renameTable(oldName, newName)
Seq.empty[Row]
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I left this line intentionally!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see.

@andrewor14
Copy link
Contributor

Looks great! Only minor comments.

# Conflicts:
#	sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
@SparkQA
Copy link

SparkQA commented Apr 14, 2016

Test build #55782 has finished for PR 12324 at commit e82aa47.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

assert(!catalog.tableExists(TableIdentifier(oldViewName)))
assert(catalog.tableExists(TableIdentifier(newViewName)))

sql(s"DROP VIEW $newViewName")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withView will help us drop the view at last.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, remove it now. Thanks!

@cloud-fan
Copy link
Contributor

LGTM except some minor comments

@SparkQA
Copy link

SparkQA commented Apr 14, 2016

Test build #55815 has finished for PR 12324 at commit db7f931.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@yhuai
Copy link
Contributor

yhuai commented Apr 14, 2016

Thanks. Merging to master.

@asfgit asfgit closed this in 0d22092 Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants