Interface SupportsPartitions


@Evolving public interface SupportsPartitions
Interface for tables that support partitions.
  • 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

      Partition getPartition(String partitionName) throws NoSuchPartitionException
      Get a partition by partition name, you may get one of the following types of partitions: It depends on the Table.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

      default boolean partitionExists(String partitionName)
      Check if a partition exists.
      Parameters:
      partitionName - The name of the partition.
      Returns:
      True if the partition exists, false otherwise.
    • addPartition

      Partition addPartition(Partition partition) throws PartitionAlreadyExistsException
      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

      boolean dropPartition(String partitionName)
      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

      default boolean purgePartition(String partitionName) throws UnsupportedOperationException
      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.