You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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 threadhere (<- link to https://mail-archives.apache.org/mod_mbox/flink-dev/)

JIRAhere (<- link to https://issues.apache.org/jira/browse/FLINK-XXXX)

Released: <Flink Version>

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

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, this behavior does not satisfy the partial column update requirements of some storage systems which allow storing null values.

Let's explain the scenario further, 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 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 table t1 which has a primary key `a`:

{code}

  create table t1 (
    `a` BIGINT,
    `b` STRING,
    `c` STRING,
    `d` STRING,
    `e` DOUBLE,
    `f` BIGINT,
    `g` INT,
    primary key(`a`) not enforced
  ) with (
    ...
  )

{code}

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 table, ideally the two insertions will not affect each others' column

{code}

insert into t1 (a, b, c, d)
select a, b, c, d from s1 where ...;

insert into t1 (a, e, f, g)
select a, e, f, g from s2 where ...;
{code}

The current problem is that connectors cannot distinguish whether the null value of a column is really from the user's data or whether it is a null value populated because of partial insert behavior.
Let's see the execution plan fragment corresponding to the first insert statement in the above example:
{code}
Sink(table=[default_catalog.default_database.t1], fields=[a, b, c, d, EXPR$3, EXPR$4, EXPR$5])
+- Calc(select=[a, b, c, d, null:VARCHAR(2147483647) AS EXPR$3, null:BIGINT AS EXPR$4, null:INTEGER AS EXPR$5])
{code}
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 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

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

If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.

  • No labels