-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-17180][SPARK-17309][SPARK-17323][SQL] create AlterViewAsCommand to handle ALTER VIEW AS #14874
Conversation
Test build #64645 has finished for PR 14874 at commit
|
*/ | ||
override def visitAlterViewQuery(ctx: AlterViewQueryContext): LogicalPlan = withOrigin(ctx) { | ||
createView( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, we can remove this function createView
. It is only being used by visitCreateView
. We just need to directly create a CreateViewCommand
in visitCreateView
This is another bug in the existing hive> create view t1_view comment 'test_comment' TBLPROPERTIES ('p1'='v1') as select * from t1;
hive> alter view t1_view as select col from t1;
After |
bbc08d9
to
5b139d9
Compare
@gatorsmile good catch! I have fixed it, thanks! |
Test build #64690 has finished for PR 14874 at commit
|
} | ||
|
||
test("ALTER VIEW AS should keep the previous table properties, comment, create_time, etc.") { | ||
withTempView("test_view") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_view
is not a temporary view, right?
LGTM except one minor comment. |
|
||
test("ALTER VIEW AS should alter permanent view if view name has database part") { | ||
withTempView("test_view") { | ||
withView("test_view") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on my understanding, this will drop the temporary view because the resolution preference of drop view
and then withTempView
is unable to find any temporary view.
Test build #64703 has finished for PR 14874 at commit
|
thanks for the review, merging to master! |
…ommand to handle ALTER VIEW AS ## What changes were proposed in this pull request? Currently we use `CreateViewCommand` to implement ALTER VIEW AS, which has 3 bugs: 1. SPARK-17180: ALTER VIEW AS should alter temp view if view name has no database part and temp view exists 2. SPARK-17309: ALTER VIEW AS should issue exception if view does not exist. 3. SPARK-17323: ALTER VIEW AS should keep the previous table properties, comment, create_time, etc. The root cause is, ALTER VIEW AS is quite different from CREATE VIEW, we need different code path to handle them. However, in `CreateViewCommand`, there is no way to distinguish ALTER VIEW AS and CREATE VIEW, we have to introduce extra flag. But instead of doing this, I think a more natural way is to separate the ALTER VIEW AS logic into a new command. backport #14874 to 2.0 ## How was this patch tested? new tests in SQLViewSuite Author: Wenchen Fan <wenchen@databricks.com> Closes #14893 from cloud-fan/minor4.
What changes were proposed in this pull request?
Currently we use
CreateViewCommand
to implement ALTER VIEW AS, which has 3 bugs:The root cause is, ALTER VIEW AS is quite different from CREATE VIEW, we need different code path to handle them. However, in
CreateViewCommand
, there is no way to distinguish ALTER VIEW AS and CREATE VIEW, we have to introduce extra flag. But instead of doing this, I think a more natural way is to separate the ALTER VIEW AS logic into a new command.How was this patch tested?
new tests in SQLViewSuite