-
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-48720][SQL] Align the command ALTER TABLE ... UNSET TBLPROPERTIES ...
in v1 and v2
#47097
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d5d1f9b
[SPARK-48720][SQL] Fix `IF EXISTS` ignored for `ALTER TABLE ... UNSET…
panbingkun 88e4a30
Merge branch 'master' into alter_unset_table
panbingkun 31cbde1
Merge branch 'master' into alter_unset_table
panbingkun 1d3b582
Merge branch 'master' into alter_unset_table
panbingkun 0de8ddf
update
panbingkun 5733fbb
update
panbingkun 4d5df8b
Merge branch 'master' into alter_unset_table
panbingkun 9a8dcf3
remove ifExists logical
panbingkun fe674fe
fix
panbingkun 1c0c260
update docs/sql-ref-syntax-ddl-alter-table.md
panbingkun a964a0f
Merge branch 'master' into alter_unset_table
panbingkun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...cala/org/apache/spark/sql/execution/command/AlterTableUnsetTblPropertiesParserSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.execution.command | ||
|
||
import org.apache.spark.SparkThrowable | ||
import org.apache.spark.sql.catalyst.analysis.{AnalysisTest, UnresolvedTable} | ||
import org.apache.spark.sql.catalyst.parser.CatalystSqlParser.parsePlan | ||
import org.apache.spark.sql.catalyst.parser.ParseException | ||
import org.apache.spark.sql.catalyst.plans.logical.UnsetTableProperties | ||
import org.apache.spark.sql.test.SharedSparkSession | ||
|
||
class AlterTableUnsetTblPropertiesParserSuite extends AnalysisTest with SharedSparkSession { | ||
|
||
private def parseException(sqlText: String): SparkThrowable = { | ||
intercept[ParseException](sql(sqlText).collect()) | ||
} | ||
|
||
// ALTER TABLE table_name UNSET TBLPROPERTIES [IF EXISTS] ('comment', 'key'); | ||
test("alter table: alter table properties") { | ||
val sql1 = "ALTER TABLE table_name UNSET TBLPROPERTIES ('comment', 'test')" | ||
val sql2 = "ALTER TABLE table_name UNSET TBLPROPERTIES IF EXISTS ('comment', 'test')" | ||
|
||
comparePlans( | ||
parsePlan(sql1), | ||
UnsetTableProperties( | ||
UnresolvedTable(Seq("table_name"), "ALTER TABLE ... UNSET TBLPROPERTIES", | ||
suggestAlternative = true), | ||
Seq("comment", "test"), | ||
ifExists = false)) | ||
comparePlans( | ||
parsePlan(sql2), | ||
UnsetTableProperties( | ||
UnresolvedTable(Seq("table_name"), "ALTER TABLE ... UNSET TBLPROPERTIES", | ||
suggestAlternative = true), | ||
Seq("comment", "test"), | ||
ifExists = true)) | ||
} | ||
|
||
test("alter table unset properties - property values must NOT be set") { | ||
val sql = "ALTER TABLE my_tab UNSET TBLPROPERTIES('key_without_value', 'key_with_value'='x')" | ||
checkError( | ||
exception = parseException(sql), | ||
errorClass = "_LEGACY_ERROR_TEMP_0035", | ||
parameters = Map("message" -> "Values should not be specified for key(s): [key_with_value]"), | ||
context = ExpectedContext( | ||
fragment = sql, | ||
start = 0, | ||
stop = 80)) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The tests have been migrated to
AlterTableUnsetTblPropertiesParserSuite