Skip to content

Commit

Permalink
Revert "[SPARK-33650][SQL] Fix the error from ALTER TABLE .. ADD/DROP…
Browse files Browse the repository at this point in the history
… PARTITION for non-supported partition management table"

This reverts commit 8594958.
  • Loading branch information
dongjoon-hyun committed Dec 4, 2020
1 parent b6b45bc commit dea3a33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,12 +996,12 @@ trait CheckAnalysis extends PredicateHelper {
private def checkAlterTablePartition(
table: Table, parts: Seq[PartitionSpec]): Unit = {
(table, parts) match {
case (table, _) if !table.isInstanceOf[SupportsPartitionManagement] =>
failAnalysis(s"Table ${table.name()} can not alter partitions.")

case (_, parts) if parts.exists(_.isInstanceOf[UnresolvedPartitionSpec]) =>
failAnalysis("PartitionSpecs are not resolved")

case (table, _) if !table.isInstanceOf[SupportsPartitionManagement] =>
failAnalysis(s"Table ${table.name()} can not alter partitions.")

// Skip atomic partition tables
case (_: SupportsAtomicPartitionManagement, _) =>
case (_: SupportsPartitionManagement, parts) if parts.size > 1 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,4 @@ class AlterTablePartitionV2SQLSuite extends DatasourceV2SQLBase {
assert(!partTable.partitionExists(expectedPartition))
}
}

test("SPARK-33650: add/drop partition into a table which doesn't support partition management") {
val t = "testcat.ns1.ns2.tbl"
withTable(t) {
spark.sql(s"CREATE TABLE $t (id bigint, data string) USING _")
Seq(
s"ALTER TABLE $t ADD PARTITION (id=1)",
s"ALTER TABLE $t DROP PARTITION (id=1)"
).foreach { alterTable =>
val errMsg = intercept[AnalysisException] {
spark.sql(alterTable)
}.getMessage
assert(errMsg.contains(s"Table $t can not alter partitions"))
}
}
}
}

0 comments on commit dea3a33

Please sign in to comment.