Skip to content

Commit 89d22f4

Browse files
author
Davies Liu
committed
disallow on datasource table
1 parent c5edbdf commit 89d22f4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,16 @@ case class AlterTableRecoverPartitionsCommand(
453453
throw new AnalysisException(
454454
s"Operation not allowed: ALTER TABLE RECOVER PARTITIONS on temporary tables: $tableName")
455455
}
456+
if (DDLUtils.isDatasourceTable(table)) {
457+
throw new AnalysisException(
458+
s"Operation not allowed: ALTER TABLE RECOVER PARTITIONS on datasource tables: $tableName")
459+
}
456460
if (table.tableType != CatalogTableType.EXTERNAL) {
457461
throw new AnalysisException(
458462
s"Operation not allowed: ALTER TABLE RECOVER PARTITIONS only works on external " +
459463
s"tables: $tableName")
460464
}
461-
if (table.partitionColumnNames.isEmpty) {
465+
if (DDLUtils.isTablePartitioned(table)) {
462466
throw new AnalysisException(
463467
s"Operation not allowed: ALTER TABLE RECOVER PARTITIONS only works on partitioned " +
464468
s"tables: $tableName")

sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,15 @@ case class RepairTableCommand(tableName: TableIdentifier) extends RunnableComman
409409
throw new AnalysisException(
410410
s"Operation not allowed: MSCK REPAIR TABLE on temporary tables: $tableName")
411411
}
412+
if (DDLUtils.isDatasourceTable(table)) {
413+
throw new AnalysisException(
414+
s"Operation not allowed: MSCK REPAIR TABLE on datasource tables: $tableName")
415+
}
412416
if (table.tableType != CatalogTableType.EXTERNAL) {
413417
throw new AnalysisException(
414418
s"Operation not allowed: MSCK REPAIR TABLE only works on external tables: $tableName")
415419
}
416-
if (table.partitionColumnNames.isEmpty) {
420+
if (DDLUtils.isTablePartitioned(table)) {
417421
throw new AnalysisException(
418422
s"Operation not allowed: MSCK REPAIR TABLE only works on partitioned tables: $tableName")
419423
}

0 commit comments

Comments
 (0)