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

Compare with Current View Page History

« Previous Version 4 Next »

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

In FLIP-218, Flink support CREATE TABLE AS SELECT  statement which allows users to create new tables based on existing tables or query result. It's convenient for data analysts and data scientists to manage their data. However, Flink does not currently support the REPLACE TABLE AS SELECT  statment which enables users to replace an existing table with new data. With REPLACE TABLE AS SELECT , they won't need to drop the table firstly, and use CREATE TABLE AS SELECT  then. Only one single REPLACE TABLE AS SELCT  statement can meet their needs.

So, this FLIP is aimed to support REPLACE TABLE AS SELECT  statement in Flink.

Public Interfaces

Syntax

We propose add the following syntax for REPLACE TABLE AS SELECT  statement:

REPLACE TABLE table_identifier
[(
 [ < physical_column_definition >, ... ]
 [ < table_constraint >, ... ])]
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name1, col_name3, ...) ]
[ WITH ( key1=val1, key2=val2, ... ) ]
AS <table subquery>

<physical_column_definition>:
  column_name column_type [ <column_constraint> ] [COMMENT column_comment]
  
<column_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY NOT ENFORCED

<table_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY (column_name, ...) NOT ENFORCED


Also, we would like to propose to CREATE OR REPLACE TABLE AS  to wrap CREATE TABLE AS SELECT  and REPLACE TABLE AS SELECT  which will create table if the table to be replaced doesn't exist.

CREATE OR REPLACE TABLE table_identifier
[(
 [ < physical_column_definition >, ... ]
 [ < table_constraint >, ... ])]
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name1, col_name3, ...) ]
[ WITH ( key1=val1, key2=val2, ... ) ]
AS <table subquery>

<physical_column_definition>:
  column_name column_type [ <column_constraint> ] [COMMENT column_comment]
  
<column_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY NOT ENFORCED

<table_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY (column_name, ...) NOT ENFORCED


Public Interfaces Change

We propose the following public interface changes for REPLACE TABLE AS SELECT  statement:

 


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