S
- Java class of source valuesT
- Java class of transformed valuespublic interface Transform<S,T>
extends java.io.Serializable
Implementations of this interface can be used to transform values, check or types, and project
predicates
to predicates on partition values.
Modifier and Type | Method and Description |
---|---|
default T |
apply(S value)
Deprecated.
use
bind(Type) instead; will be removed in 2.0.0 |
default SerializableFunction<S,T> |
bind(Type type)
Returns a function that applies this transform to values of the given
type . |
boolean |
canTransform(Type type)
Checks whether this function can be applied to the given
Type . |
default java.lang.String |
dedupName()
Return the unique transform name to check if similar transforms for the same source field are
added multiple times in partition spec builder.
|
Type |
getResultType(Type sourceType)
Returns the
Type produced by this transform given a source type. |
default boolean |
isIdentity()
Return whether this transform is the identity transform.
|
default boolean |
isVoid()
Return whether this transform is the void transform.
|
default boolean |
preservesOrder()
Whether the transform preserves the order of values (is monotonic).
|
UnboundPredicate<T> |
project(java.lang.String name,
BoundPredicate<S> predicate)
Transforms a
predicate to an inclusive predicate on the partition values
produced by the transform. |
UnboundPredicate<T> |
projectStrict(java.lang.String name,
BoundPredicate<S> predicate)
Transforms a
predicate to a strict predicate on the partition values
produced by the transform. |
default boolean |
satisfiesOrderOf(Transform<?,?> other)
Whether ordering by this transform's result satisfies the ordering of another transform's
result.
|
default java.lang.String |
toHumanString(T value)
Deprecated.
use
toHumanString(Type, Object) instead; will be removed in 2.0.0 |
default java.lang.String |
toHumanString(Type type,
T value) |
@Deprecated default T apply(S value)
bind(Type)
instead; will be removed in 2.0.0value
- a source valuedefault SerializableFunction<S,T> bind(Type type)
type
.type
- an Iceberg Type
Function
that applies this transform to values of the given type.boolean canTransform(Type type)
Type
.type
- a typeType getResultType(Type sourceType)
Type
produced by this transform given a source type.sourceType
- a typedefault boolean preservesOrder()
A transform preserves order for values when for any given a and b, if a < b then apply(a) <= apply(b).
default boolean satisfiesOrderOf(Transform<?,?> other)
For example, sorting by day(ts) will produce an ordering that is also by month(ts) or year(ts). However, sorting by day(ts) will not satisfy the order of hour(ts) or identity(ts).
UnboundPredicate<T> project(java.lang.String name, BoundPredicate<S> predicate)
predicate
to an inclusive predicate on the partition values
produced by the transform.
This inclusive transform guarantees that if pred(v) is true, then projected(apply(v)) is true.
name
- the field name for partition valuespredicate
- a predicate for source valuesUnboundPredicate<T> projectStrict(java.lang.String name, BoundPredicate<S> predicate)
predicate
to a strict predicate on the partition values
produced by the transform.
This strict transform guarantees that if strict(apply(v)) is true, then pred(v) is also true.
name
- the field name for partition valuespredicate
- a predicate for source valuesdefault boolean isIdentity()
default boolean isVoid()
@Deprecated default java.lang.String toHumanString(T value)
toHumanString(Type, Object)
instead; will be removed in 2.0.0null values will return "null"
value
- a transformed valuedefault java.lang.String dedupName()