Versions Compared

Key

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


Status

...

Page properties


Discussion thread

...

...

Vote thread
JIRA

Jira
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyFLINK-4557

Release1.3


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

JIRA: 

Released: 

Motivation

As discussed above, current flink sql metadata column is fixed and cannot be compatible with metadata change of a certain connector.

DEFAULT constraint is a good way to solve this issue. Actually the column DEFAULT is a reasonable feature and can also help in other cases (e.g. regular or physical columns).

so we propose this flip.

Public Interfaces

DEFAULT Syntax

CREATE TABLE table_name (

     metadataCol VARCHAR METADATA DEFAULT 'UNKNOWN',
  col VARCHAR DEFAULT '',

    col2 VARCHAR DEFAULT NULL

...

combine with VIRTUAL:

CREATE TABLE table_name (

     metadataCol_1 VARCHAR METADATA DEFAULT 'UNKNOWN',

     metadataCol_2 VARCHAR METADATA

VIRTUAL

DEFAULT 'UNKNOWN' VIRTUAL,
  col_1 VARCHAR DEFAULT '',

   

col2

col_2 VARCHAR DEFAULT NULL
) WITH (
  ...
)

 

Proposed Changes

Flink Table API & SQL handles DEFAULT constraint in the ddl.

...

The proposed syntax also follows this concept.

Implementation

Add DEFAULT keyword like current VIRTUAL keywordsql column DEFAULT constraint. Implemented details to be added.

Compatibility, Deprecation, and Migration Plan

The DEFAULT column constraint is an optional KEYWORD to let uses define default value, so we don't need to deal with migration plan. And here is no need to add deprecationdeprecations.

Test Plan

Add DEFAULT sql column constraint test cases & ensure all table & sql cases passed

...