Class Transforms

java.lang.Object
org.apache.iceberg.transforms.Transforms

public class Transforms extends Object
Factory methods for transforms.

Most users should create transforms using a PartitionSpec.builderFor(Schema) partition spec builder}.

See Also:
  • Method Details

    • fromString

      public static Transform<?,?> fromString(String transform)
    • fromString

      public static Transform<?,?> fromString(Type type, String transform)
    • identity

      @Deprecated public static <T> Transform<T,T> identity(Type type)
      Deprecated.
      use identity() instead; will be removed in 2.0.0
      Returns an identity Transform that can be used for any type.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      type - the source type for the transform
      Returns:
      an identity transform
    • year

      @Deprecated public static <T> Transform<T,Integer> year(Type type)
      Deprecated.
      use year() instead; will be removed in 2.0.0
      Returns a year Transform for date or timestamp types.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      type - the source type for the transform
      Returns:
      a year transform
    • month

      @Deprecated public static <T> Transform<T,Integer> month(Type type)
      Deprecated.
      use month() instead; will be removed in 2.0.0
      Returns a month Transform for date or timestamp types.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      type - the source type for the transform
      Returns:
      a month transform
    • day

      @Deprecated public static <T> Transform<T,Integer> day(Type type)
      Deprecated.
      use day() instead; will be removed in 2.0.0
      Returns a day Transform for date or timestamp types.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      type - the source type for the transform
      Returns:
      a day transform
    • hour

      @Deprecated public static <T> Transform<T,Integer> hour(Type type)
      Deprecated.
      use hour() instead; will be removed in 2.0.0
      Returns an hour Transform for timestamps.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      type - the source type for the transform
      Returns:
      an hour transform
    • bucket

      @Deprecated public static <T> Transform<T,Integer> bucket(Type type, int numBuckets)
      Deprecated.
      use bucket(int) instead; will be removed in 2.0.0
      Returns a bucket Transform for the given type and number of buckets.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      type - the source type for the transform
      numBuckets - the number of buckets for the transform to produce
      Returns:
      a transform that buckets values into numBuckets
    • truncate

      @Deprecated public static <T> Transform<T,T> truncate(Type type, int width)
      Deprecated.
      use truncate(int) instead; will be removed in 2.0.0
      Returns a truncate Transform for the given type and width.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      type - the source type for the transform
      width - the width to truncate data values
      Returns:
      a transform that truncates the given type to width
    • identity

      public static <T> Transform<T,T> identity()
      Returns an identity Transform that can be used for any type.
      Type Parameters:
      T - Java type passed to this transform
      Returns:
      an identity transform
    • year

      public static <T> Transform<T,Integer> year()
      Returns a year Transform for date or timestamp types.
      Type Parameters:
      T - Java type passed to this transform
      Returns:
      a year transform
    • month

      public static <T> Transform<T,Integer> month()
      Returns a month Transform for date or timestamp types.
      Type Parameters:
      T - Java type passed to this transform
      Returns:
      a month transform
    • day

      public static <T> Transform<T,Integer> day()
      Returns a day Transform for date or timestamp types.
      Type Parameters:
      T - Java type passed to this transform
      Returns:
      a day transform
    • hour

      public static <T> Transform<T,Integer> hour()
      Returns an hour Transform for timestamp types.
      Type Parameters:
      T - Java type passed to this transform
      Returns:
      an hour transform
    • bucket

      public static <T> Transform<T,Integer> bucket(int numBuckets)
      Returns a bucket Transform for the given number of buckets.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      numBuckets - the number of buckets for the transform to produce
      Returns:
      a transform that buckets values into numBuckets
    • truncate

      public static <T> Transform<T,T> truncate(int width)
      Returns a truncate Transform for the given width.
      Type Parameters:
      T - Java type passed to this transform
      Parameters:
      width - the width to truncate data values
      Returns:
      a transform that truncates the given type to width
    • alwaysNull

      public static <T> Transform<T,Void> alwaysNull()
      Returns a Transform that always produces null.
      Type Parameters:
      T - Java type accepted by the transform.
      Returns:
      a transform that always produces null (the void transform).