Package org.apache.gravitino.rel
Interface SupportsPartitions
Interface for tables that support partitions.
-
Method Summary
Modifier and TypeMethodDescriptionaddPartition
(Partition partition) Add a partition with specified name and properties to the table.boolean
dropPartition
(String partitionName) Drop a partition with specified name.getPartition
(String partitionName) Get a partition by partition name, you may get one of the following types of partitions:IdentityPartition
ListPartition
RangePartition
It depends on theTable.partitioning()
.String[]
List all partition names of the tableList all partitionsdefault boolean
partitionExists
(String partitionName) Check if a partition exists.default boolean
purgePartition
(String partitionName) If the table supports purging, drop a partition with specified name and completely remove partition data by skipping a trash.
-
Method Details
-
listPartitionNames
String[] listPartitionNames()List all partition names of the table- Returns:
- The list of partition names
-
listPartitions
Partition[] listPartitions()List all partitions- Returns:
- The list of partitions
-
getPartition
Get a partition by partition name, you may get one of the following types of partitions: It depends on theTable.partitioning()
. A Java type conversion is required before getting the specific partition, for example:RangePartition rangePartition = (RangePartition) table.supportPartitions().getPartition("p20200321"); Literal<?> upper = rangePartition.upper(); Literal<?> lower = rangePartition.lower(); ...
- Parameters:
partitionName
- the name of the partition- Returns:
- the partition
- Throws:
NoSuchPartitionException
- if the partition does not exist
-
partitionExists
Check if a partition exists.- Parameters:
partitionName
- The name of the partition.- Returns:
- True if the partition exists, false otherwise.
-
addPartition
Add a partition with specified name and properties to the table.- Parameters:
partition
- The partition to add.- Returns:
- The created partition.
- Throws:
PartitionAlreadyExistsException
- If the partition already exists.
-
dropPartition
Drop a partition with specified name.- Parameters:
partitionName
- the name of the partition- Returns:
- true if the partition is deleted successfully, false if the partition does not exist.
-
purgePartition
If the table supports purging, drop a partition with specified name and completely remove partition data by skipping a trash. If the table is an external table or does not support purging partitions,UnsupportedOperationException
is thrown.- Parameters:
partitionName
- The name of the partition.- Returns:
- true if the partition is purged, false if the partition does not exist.
- Throws:
UnsupportedOperationException
- If partition purging is not supported.
-