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 @@ -93,7 +93,7 @@ trait CheckAnalysis extends PredicateHelper {

case alter: AlterTable =>
alter.table match {
case u @ UnresolvedTableWithViewExists(view) if !view.isTempView =>
case u @ UnresolvedTableWithViewExists(view) =>
u.failAnalysis("Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead")
case _ =>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ ALTER TABLE temp_view CHANGE a TYPE INT COMMENT 'this is column a'
struct<>
-- !query 20 output
org.apache.spark.sql.AnalysisException
temp_view is a temp view not a table.; line 1 pos 0
Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead; line 1 pos 0
Copy link
Member

Choose a reason for hiding this comment

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

Hi, @cloud-fan and @imback82
Cannot alter a view with ALTER TABLE. looks okay, but Please use ALTER VIEW instead looks like we mislead the users to try ALTER VIEW temp_view CHANGE a TYPE INT COMMENT 'this is column a'.

Copy link
Member

@dongjoon-hyun dongjoon-hyun Jan 22, 2020

Choose a reason for hiding this comment

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

The other changes in this PR are the same. The directional message parts look misleading.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good point. How about just Cannot alter a temp view with ALTER TABLE. as the error message?

Copy link
Member

Choose a reason for hiding this comment

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

+1 for @cloud-fan 's advice.



-- !query 21
Expand All @@ -212,7 +212,7 @@ ALTER TABLE global_temp.global_temp_view CHANGE a TYPE INT COMMENT 'this is colu
struct<>
-- !query 22 output
org.apache.spark.sql.AnalysisException
global_temp.global_temp_view is a temp view not a table.; line 1 pos 0
Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead; line 1 pos 0


-- !query 23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
// For v2 ALTER TABLE statements, we have better error message saying view is not supported.
assertAnalysisError(
s"ALTER TABLE $viewName SET LOCATION '/path/to/your/lovely/heart'",
s"$viewName is a temp view not a table")
"Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead")

// For the following v2 ALERT TABLE statements, relations are first resolved before
// unsupported operations are checked.
assertAnalysisError(
s"ALTER TABLE $viewName PARTITION (a='4') SET LOCATION '/path/to/home'",
s"$viewName is a temp view not a table")
"Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,8 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
val e = intercept[AnalysisException] {
sql("ALTER TABLE tmp_v ADD COLUMNS (c3 INT)")
}
assert(e.message.contains("tmp_v is a temp view not a table"))
assert(
e.message.contains("Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead"))
}
}

Expand Down