Versions Compared

Key

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

This page is meant as a template for writing a FLIP. To create a FLIP choose Tools->Copy on this page and modify with your content and replace the heading with the next FLIP number and a description of your issue. Replace anything in italics with your own description.

Status

Current state[One of "Under Discussion", "Accepted", "Rejected"]

...

Discussion thread

...

...

...

...

thread/kfqkmtlpk2k3q3cc3l8p0j7lg6b3o0sj
JIRA

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyFLINK-31487

Release<Flink Version>

...

Released: <Flink Version>

...

Motivation

To support connectors in avoiding overwriting non-target columns with null values when processing partial column updates, we propose adding information on the target column list to DynamicTableSink#Context.

FLINK-18726 supports inserting statements with specified column list, it fills null values (or potentially declared default values in the future) for columns not appearing in the column list of insert statement to the target table. While in the field of big data, But this behavior does not satisfy the some partial column update requirements of some storage systems which allow storing null values.

Let's explain the scenario further, denormalized table(or the commonly known 'wide table') model is a common data modeling method, which connects multiple tables to form a unified wide table to improve query and analysis efficiency.
The data of wide denormalized table comes from different source tables. When writing or updating data, it usually adopts the mode of specifying the column list to write.

For example, there is a wide denormalized table t1 which has a primary key `a`:

...

where column b, c, d from s1 table, column e, f, g from s2 table,
by different processing data from the source table s1 and s2,  the two insertions specify a different column list written to the wide denormalized table, ideally the two insertions will not affect each others' column

...

The current connector implementor has no way of knowing that the last three fields were added by the planner and not from real user data. The user has to declare several different schemas (containing only partial column information and no overlap except for the primary key) to get around the current problem. 

By adding targetColumnList target column list information to the DynamicTableSink#Context, this problem can be solved.

Public Interfaces

Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.

A public interface is any change to the following:

  • DataStream and DataSet API, including classes related to that, such as StreamExecutionEnvironment
  • Classes marked with the @Public annotation
  • On-disk binary formats, such as checkpoints/savepoints
  • User-facing scripts/command-line tools, i.e. bin/flink, Yarn scripts, Mesos scripts
  • Configuration settings
  • Exposed monitoring information

Proposed Changes

Add new getTargetColumns to DynamicTableSink#Context.

Code Block
languagejava
       /**
         * Returns an {@link Optional} array of column index paths related to user specified target
         * column list or {@link Optional#empty()} when not specified. The array indices are 0-based
         * and support composite columns within (possibly nested) structures.
         *
         * <p>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
         *       return {@code [[0], [1, 1]]}. The statement 'insert into target select ...' without
         *       specifying a column list will return {@link Optional#empty()}.
         *   <li>update: 'update target set a=1, b.b1=2 where ...', the column list will be 'a,
         *       b.b1', will return {@code [[0], [1, 0]]}.
         * </ul>
         *
         * <p>Note: will always return empty for the delete statement because it has no column list.
         */
         Optional<int[][]> getTargetColumns();


Proposed Changes

The internal SinkRuntimeProviderContext will support new constructor with targetColumns param, this can be used by connectors to recognize the user-specified column list.

Note: currently nested columns in column list of an insert/update statement is unsupported (as described in FLINK-31301 & FLINK-31344), so we can make this flip support simple columns first and then support nested columns after FLINK-31301 & FLINK-31344 fixed. Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.

Compatibility, Deprecation, and Migration Plan

  • What impact (if any) will there be on existing users? 
  • If we are changing behavior how will we phase out the older behavior? 
  • If we need special migration tools, describe them here.
  • When will we remove the existing behavior?

Test Plan

Describe in few sentences how the FLIP will be tested. We are mostly interested in system tests (since unit-tests are specific to implementation details). How will we know that the implementation works as expected? How will we know nothing broke?

Rejected Alternatives

...

This is a compatible change, the newly added information has no effect on the behavior of existing connectors, but simply provides additional information to satisfy the connector developers who need it

Test Plan

Related plan test will be added, and also update the test values sink for it cases.

Rejected Alternatives