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[Under Discussion]

Discussion thread: https://lists.apache.org/thread/dwrbsvdlkyytvsq71mmfcqbvfq5sys01

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. physical columns).

so we propose this flip.

Public Interfaces

DEFAULT Syntax

CREATE TABLE table_name (

     metadataCol_1 VARCHAR METADATA DEFAULT 'UNKNOWN',

     metadataCol_2 VARCHAR METADATA VIRTUAL DEFAULT 'UNKNOWN',
  col_1 VARCHAR DEFAULT '',

    col_2 VARCHAR DEFAULT NULL
) WITH (
  ...
)

Proposed Changes

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

This allows user set optional default value for the columns(physical columns/metadata columns). The only difference between current column and DEFAULT column is that we have a default value on that column.

The proposed syntax also follows this concept.

Implementation

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

Compatibility, Deprecation, and Migration Plan

The DEFAULT 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 deprecations.

Test Plan

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

Rejected Alternatives



  • No labels