Package org.apache.iceberg
Class PartitionSpec
- java.lang.Object
-
- org.apache.iceberg.PartitionSpec
-
- All Implemented Interfaces:
java.io.Serializable
public class PartitionSpec extends java.lang.Object implements java.io.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PartitionSpec.Builder
Used to create validpartition specs
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PartitionSpec.Builder
builderFor(Schema schema)
Creates a newpartition spec builder
for the givenSchema
.boolean
compatibleWith(PartitionSpec other)
Returns true if this spec is equivalent to the other, with partition field ids ignored.boolean
equals(java.lang.Object other)
java.util.List<PartitionField>
fields()
Returns the list ofpartition fields
for this spec.java.util.List<PartitionField>
getFieldsBySourceId(int fieldId)
Returns thefield
that partitions the given source fieldint
hashCode()
java.util.Set<java.lang.Integer>
identitySourceIds()
Returns the source field ids for identity partitions.boolean
isPartitioned()
boolean
isUnpartitioned()
java.lang.Class<?>[]
javaClasses()
java.lang.String
partitionToPath(StructLike data)
Types.StructType
partitionType()
Returns aTypes.StructType
for partition data defined by this spec.Schema
schema()
Returns theSchema
for this spec.int
specId()
Returns the ID of this spec.java.lang.String
toString()
static PartitionSpec
unpartitioned()
Returns a spec for unpartitioned tables.
-
-
-
Method Detail
-
specId
public int specId()
Returns the ID of this spec.
-
fields
public java.util.List<PartitionField> fields()
Returns the list ofpartition fields
for this spec.
-
isPartitioned
public boolean isPartitioned()
-
isUnpartitioned
public boolean isUnpartitioned()
-
getFieldsBySourceId
public java.util.List<PartitionField> getFieldsBySourceId(int fieldId)
Returns thefield
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
public Types.StructType partitionType()
Returns aTypes.StructType
for partition data defined by this spec.
-
javaClasses
public java.lang.Class<?>[] javaClasses()
-
partitionToPath
public java.lang.String partitionToPath(StructLike data)
-
compatibleWith
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
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
identitySourceIds
public java.util.Set<java.lang.Integer> identitySourceIds()
Returns the source field ids for identity partitions.- Returns:
- a set of source ids for the identity partitions.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
unpartitioned
public static PartitionSpec unpartitioned()
Returns a spec for unpartitioned tables.- Returns:
- a partition spec with no partitions
-
builderFor
public static PartitionSpec.Builder builderFor(Schema schema)
Creates a newpartition spec builder
for the givenSchema
.- Parameters:
schema
- a schema- Returns:
- a partition spec builder for the given schema
-
-