Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
package org.apache.flink.table.connector.sink.abilities;  

/**
 * Interface for {@link DynamicTableSink}s that support target column writing.
 *
 * <p>The planner will parse target columns from the DML clause and call {@link
 * #applyTargetColumns(int[][])} to pass an array of column index paths to sink.
 *
 * <p>The array indices are 0-based and support composite columns within (possibly nested)
 * structures. This information comes from the column list of the DML clause, e.g., for a sink table
 * t1 which schema is: {@code a STRING, b ROW < b1 INT, b2 STRING>, c BIGINT}
 *
 * <ul>
 *   <li>insert: 'insert into t1(a, b.b2) ...', the column list will be 'a, b.b2', and will provide
 *       {@code [[0], [1, 1]]}. The statement 'insert into t1 select ...' will withoutnot specifyingapply athis
 *       column list will provide null inputability.
 *   <li>update: 'update t1 set a=1, b.b1=2 where ...', the column list will be 'a, b.b1', and will
 *       provide {@code [[0], [1, 0]]}.
 * </ul>
 *
 * <p>Note: Planner will alwaysnot provideapply athis nullable arrayability for the delete statement because it has no column
 * column list.
 *
 * <p>A sink can use this information to perform target columns writing.
 *
 * <p>If this interface is implemented and {@link #applyTargetColumns(int[][])} returns true. The
 * planner will use this information for plan optimization such as sink reuse.
 */
@PublicEvolving
public interface SupportsTargetColumnWriting {

    /**
     * Provides an array of column index paths related to user specified target column list or null
     * input when not specified.
     *
     * <p>See the documentation of {@link SupportsTargetColumnWriting} for more information.
     *
     * @param targetColumns column index paths
     * @return true if the target columns are applied successfully, false otherwise.
     */
    boolean applyTargetColumns(@Nullable int[][] targetColumns);
} 


TargetColumnWritingSpec: A sub-class of SinkAbilitySpec that supports TargetColumnWriting

...