Interface SortOrderProvider


public interface SortOrderProvider
A specification for providing SortOrder while writing to an iceberg table.
  • Method Summary

    Modifier and Type
    Method
    Description
    fromSortId(int id)
    Use the sort order with the given ID to sort new data while writing to the iceberg table.
    fromSortOrder(org.apache.iceberg.SortOrder sortOrder)
    Use the given sort order directly to sort new data while writing to the iceberg table.
    Do not sort the data while writing new data to the iceberg table.
    Use the default Table.sortOrder() of the table while writing new data.
    withFailOnUnmapped(boolean failOnUnmapped)
    Returns a sort order provider configured to fail (or not) if the sort order cannot be applied to the tables being written.
    withId(int sortOrderId)
    Returns a sort order provider that uses the current provider to determine the columns to sort on, but writes a different sort order ID to the Iceberg table.
  • Method Details

    • unsorted

      static SortOrderProvider unsorted()
      Do not sort the data while writing new data to the iceberg table.
    • useTableDefault

      static SortOrderProvider useTableDefault()
      Use the default Table.sortOrder() of the table while writing new data. If no sort order is set on the table, no sorting will be done.
    • fromSortId

      static SortOrderProvider fromSortId(int id)
      Use the sort order with the given ID to sort new data while writing to the iceberg table.
    • fromSortOrder

      static SortOrderProvider fromSortOrder(org.apache.iceberg.SortOrder sortOrder)
      Use the given sort order directly to sort new data while writing to the iceberg table. Note that the provided sort order must either have a valid SortOrder.orderId(), else this provider should be chained with an withId(int) call to set a valid order ID.
    • withId

      SortOrderProvider withId(int sortOrderId)
      Returns a sort order provider that uses the current provider to determine the columns to sort on, but writes a different sort order ID to the Iceberg table. Note that the sort order returned by the caller must satisfy the sort order corresponding to the provided sort order ID.

      For example, this provider might sort by columns {A, B, C}, but the ID written to Iceberg corresponds to a sort order with columns {A, B}.

      Parameters:
      sortOrderId - the sort order ID to write to the iceberg table
    • withFailOnUnmapped

      SortOrderProvider withFailOnUnmapped(boolean failOnUnmapped)
      Returns a sort order provider configured to fail (or not) if the sort order cannot be applied to the tables being written. By default, all providers fail if the sort order cannot be applied.
      Parameters:
      failOnUnmapped - whether to fail if the sort order cannot be applied to the tables being written. If false and the sort order cannot be applied, the tables will be written without sorting.