diff --git a/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsAtomicPartitionManagement.java b/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsAtomicPartitionManagement.java index 77706daf82f7c..665946fcf3e2a 100644 --- a/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsAtomicPartitionManagement.java +++ b/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsAtomicPartitionManagement.java @@ -98,7 +98,11 @@ void createPartitions( * @return true if partitions were deleted, false if any partition not exists * @throws NoSuchPartitionException If any partition identifier to alter doesn't exist * @throws UnsupportedOperationException If partition purging is not supported + * + * @since 3.2.0 */ - boolean purgePartitions(InternalRow[] idents) - throws NoSuchPartitionException, UnsupportedOperationException; + default boolean purgePartitions(InternalRow[] idents) + throws NoSuchPartitionException, UnsupportedOperationException { + throw new UnsupportedOperationException("Partition purge is not supported"); + } } diff --git a/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsPartitionManagement.java b/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsPartitionManagement.java index 82785b74fe9e1..409ab3f5f9335 100644 --- a/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsPartitionManagement.java +++ b/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsPartitionManagement.java @@ -83,9 +83,13 @@ void createPartition( * @return true if a partition was deleted, false if no partition exists for the identifier * @throws NoSuchPartitionException If the partition identifier to alter doesn't exist * @throws UnsupportedOperationException If partition purging is not supported + * + * @since 3.2.0 */ - boolean purgePartition(InternalRow ident) - throws NoSuchPartitionException, UnsupportedOperationException; + default boolean purgePartition(InternalRow ident) + throws NoSuchPartitionException, UnsupportedOperationException { + throw new UnsupportedOperationException("Partition purge is not supported"); + } /** * Test whether a partition exists using an {@link InternalRow ident} from the table. diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryAtomicPartitionTable.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryAtomicPartitionTable.scala index 0d81f32fe155f..c2a95cc3b8b07 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryAtomicPartitionTable.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryAtomicPartitionTable.scala @@ -73,11 +73,4 @@ class InMemoryAtomicPartitionTable ( } idents.forall(dropPartition) } - - override def purgePartitions(idents: Array[InternalRow]): Boolean = { - if (!idents.forall(partitionExists)) { - return false; - } - idents.forall(purgePartition) - } } diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryPartitionTable.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryPartitionTable.scala index a1ceb56ed76c2..e29c78c59f769 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryPartitionTable.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryPartitionTable.scala @@ -67,10 +67,6 @@ class InMemoryPartitionTable( } } - override def purgePartition(ident: InternalRow): Boolean = { - throw new UnsupportedOperationException("Partition purge is not supported") - } - def replacePartitionMetadata(ident: InternalRow, properties: util.Map[String, String]): Unit = { if (memoryTablePartitions.containsKey(ident)) { memoryTablePartitions.put(ident, properties)