Interface DestinationResolver<T>

Type Parameters:
T - type of the records written by the sink
All Superinterfaces:
Serializable
All Known Implementing Classes:
FixedDestinationResolver
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@Public @FunctionalInterface public interface DestinationResolver<T> extends Serializable
Resolves the destination table for each record, enabling one sink instance to write to many tables (dynamic destinations).

The resolver is invoked once per record on the hot write path. Implementations must be deterministic and cheap; when destinations repeat, return cached TableDestination instances instead of re-creating them per record (for example via a small Map#computeIfAbsent keyed on the varying component).

The SinkWriter.Context exposes the record's event timestamp for time-based routing (for example daily tables).

Return UnroutableRecord only for a deterministic, record-specific routing failure that the configured failure policy may safely fail, drop, or dead-letter. Returning null or throwing an unexpected exception is a resolver bug or configuration failure and always fails the write.

  • Method Summary

    Modifier and Type
    Method
    Description
    resolve(T element, org.apache.flink.api.connector.sink2.SinkWriter.Context context)
    Resolves the destination for the given record.
  • Method Details

    • resolve

      DestinationResolution resolve(T element, org.apache.flink.api.connector.sink2.SinkWriter.Context context)
      Resolves the destination for the given record.
      Parameters:
      element - the record
      context - writer context exposing the record's event timestamp and current watermark
      Returns:
      a destination table, or an explicit record-specific routing failure; never null