Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#3140] docs(partition): add docs and OAS for drop partition operation (#3141)

mchadesf114cf6c8f9d
diff --git a/docs/manage-table-partition-using-gravitino.md b/docs/manage-table-partition-using-gravitino.md
index 3b9ab3a596..2b44a1a1d2 100644
--- a/docs/manage-table-partition-using-gravitino.md
+++ b/docs/manage-table-partition-using-gravitino.md
@@ -19,13 +19,13 @@ Although many catalogs inherently manage partitions automatically, there are sce
The following table shows the partition operations supported across various catalogs in Gravitino:
-| Operation | Hive catalog | Iceberg catalog | Jdbc-Mysql catalog | Jdbc-PostgreSQL catalog |
-|-----------------------|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------|--------------------|-------------------------|
-| Add Partition | ✔ | ✘ | ✘ | ✘ |
-| Get Partition by Name | ✔ | ✘ | ✘ | ✘ |
-| List Partition Names | ✔ | ✘ | ✘ | ✘ |
-| List Partitions | ✔ | ✘ | ✘ | ✘ |
-| Drop Partition | 🚀([Coming Soon](https://github.com/datastrato/gravitino/issues/1655)) | 🚀([Coming Soon](https://github.com/datastrato/gravitino/issues/1655)) | ✘ | ✘ |
+| Operation | Hive catalog | Iceberg catalog | Jdbc-Mysql catalog | Jdbc-PostgreSQL catalog |
+|-----------------------|--------------|-------------------------------------------------------------------------------|--------------------|-------------------------|
+| Add Partition | ✔ | ✘ | ✘ | ✘ |
+| Get Partition by Name | ✔ | ✘ | ✘ | ✘ |
+| List Partition Names | ✔ | ✘ | ✘ | ✘ |
+| List Partitions | ✔ | ✘ | ✘ | ✘ |
+| Drop Partition | ✔ | 🚀([Coming Soon](https://github.com/datastrato/gravitino/issues/1655)) | ✘ | ✘ |
:::tip[WELCOME FEEDBACK]
If you need additional partition management support for a specific catalog, please feel free to [create an issue](https://github.com/datastrato/gravitino/issues/new/choose) on the [Gravitino repository](https://github.com/datastrato/gravitino).
@@ -374,5 +374,45 @@ Partition[] partitions =
.listPartitions();
```
+</TabItem>
+</Tabs>
+
+### Drop a partition by name
+
+You can drop a partition by its name via sending a `DELETE` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/tables/{partitioned_table_name}/partitions/{partition_name}` endpoint or by using the Gravitino Java client.
+The following is an example of dropping a partition by its name:
+
+<Tabs>
+<TabItem value="shell" label="Shell">
+
+```shell
+curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \
+-H "Content-Type: application/json" \
+http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tables/table/partitions/p20200321
+```
+
+:::tip
+If the partition name contains special characters, you should use [URL encoding](https://en.wikipedia.org/wiki/Percent-encoding#Reserved_characters). For example, if the partition name is `dt=2008-08-08/country=us` you should use `dt%3D2008-08-08%2Fcountry%3Dus` in the URL.
+:::
+
+</TabItem>
+<TabItem value="java" label="Java">
+
+```java
+GravitinoClient gravitinoClient = GravitinoClient
+ .builder("http://127.0.0.1:8090")
+ .withMetalake("metalake")
+ .build();
+
+// Assume that you have a partitioned table named "metalake.catalog.schema.table".
+Partition Partition =
+ gravitinoClient
+ .loadCatalog(NameIdentifier.of("metalake", "catalog"))
+ .asTableCatalog()
+ .loadTable(NameIdentifier.of("metalake", "catalog", "schema", "table"))
+ .supportPartitions()
+ .dropPartition("partition_name");
+```
+
</TabItem>
</Tabs>
\ No newline at end of file
diff --git a/docs/open-api/partitions.yaml b/docs/open-api/partitions.yaml
index dc4d7cce44..fc40b98ff5 100644
--- a/docs/open-api/partitions.yaml
+++ b/docs/open-api/partitions.yaml
@@ -105,6 +105,22 @@ paths:
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+ delete:
+ tags:
+ - partition
+ summary: Drop partition by name
+ operationId: dropPartition
+ description: Drops the specified partition
+ parameters:
+ - $ref: "#/components/parameters/purge"
+ responses:
+ "200":
+ $ref: "./openapi.yaml#/components/responses/DropResponse"
+ "400":
+ $ref: "./openapi.yaml#/components/responses/BadRequestErrorResponse"
+ "5xx":
+ $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+
components:
parameters:
@@ -117,6 +133,15 @@ components:
type: boolean
default: false
+ purge:
+ name: purge
+ in: query
+ description: Purge the partition data
+ required: false
+ schema:
+ type: boolean
+ default: false
+
partition:
name: partition
in: path
diff --git a/docs/open-api/tables.yaml b/docs/open-api/tables.yaml
index abbbfbd12d..e0e116c0f2 100644
--- a/docs/open-api/tables.yaml
+++ b/docs/open-api/tables.yaml
@@ -141,6 +141,8 @@ paths:
- table
summary: Drop table
operationId: dropTable
+ parameters:
+ - $ref: "#/components/parameters/purge"
responses:
"200":
$ref: "./openapi.yaml#/components/responses/DropResponse"
@@ -151,6 +153,15 @@ paths:
components:
+ parameters:
+ purge:
+ name: purge
+ in: query
+ description: Removes both the metadata and the directory associated with the table completely and skipping trash.
+ required: false
+ schema:
+ type: boolean
+ default: false
schemas:
TableCreateRequest: