Class PartitionSpec

java.lang.Object
org.apache.iceberg.PartitionSpec
All Implemented Interfaces:
Serializable

public class PartitionSpec extends Object implements Serializable
Represents how to produce partition data for a table.

Partition data is produced by transforming columns in a table. Each column transform is represented by a named PartitionField.

See Also:
  • Method Details Link icon

    • schema Link icon

      public Schema schema()
      Returns the Schema for this spec.
    • specId Link icon

      public int specId()
      Returns the ID of this spec.
    • fields Link icon

      public List<PartitionField> fields()
      Returns the list of partition fields for this spec.
    • isPartitioned Link icon

      public boolean isPartitioned()
    • isUnpartitioned Link icon

      public boolean isUnpartitioned()
    • toUnbound Link icon

      public UnboundPartitionSpec toUnbound()
    • getFieldsBySourceId Link icon

      public List<PartitionField> getFieldsBySourceId(int fieldId)
      Returns the field that partitions the given source field
      Parameters:
      fieldId - a field id from the source schema
      Returns:
      the field that partitions the given source field
    • partitionType Link icon

      public Types.StructType partitionType()
      Returns a Types.StructType for partition data defined by this spec.
    • rawPartitionType Link icon

      public Types.StructType rawPartitionType()
      Returns a struct matching partition information as written into manifest files. See partitionType() for a struct with field ID's potentially re-assigned to avoid conflict.
    • javaClasses Link icon

      public Class<?>[] javaClasses()
    • partitionToPath Link icon

      public String partitionToPath(StructLike data)
    • compatibleWith Link icon

      public boolean compatibleWith(PartitionSpec other)
      Returns true if this spec is equivalent to the other, with partition field ids ignored. That is, if both specs have the same number of fields, field order, field name, source columns, and transforms.
      Parameters:
      other - another PartitionSpec
      Returns:
      true if the specs have the same fields, source columns, and transforms.
    • equals Link icon

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • identitySourceIds Link icon

      public Set<Integer> identitySourceIds()
      Returns the source field ids for identity partitions.
      Returns:
      a set of source ids for the identity partitions.
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • unpartitioned Link icon

      public static PartitionSpec unpartitioned()
      Returns a spec for unpartitioned tables.
      Returns:
      a partition spec with no partitions
    • builderFor Link icon

      public static PartitionSpec.Builder builderFor(Schema schema)
      Creates a new partition spec builder for the given Schema.
      Parameters:
      schema - a schema
      Returns:
      a partition spec builder for the given schema