Versions Compared

Key

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

...

Code Block
languagesql
CREATE [ TEMPORARY ] TABLE [ IF NOT EXISTS ] table_name ( [
  {   column
    | table_constraint
    |[, ... ]
] )
[ LIKE parent_table [ like_options ] }
    [, ... ]
] )

where like_options are:

  { INCLUDING | EXCLUDING } ALL
| [{ 
     { INCLUDING | EXCLUDING } { CONSTRAINTS }
   | { INCLUDING | EXCLUDING | OVERWRITING } { GENERATED | OPTIONS } }
   [, ...]
  ]

...

Code Block
languagesql
CREATE [TEMPORARY] TABLE base_table (
    id BIGINT,
    name STRING,
    tstmp TIMESTAMP,
	PRIMARY KEY(id)
) WITH (
    ‘connector.type’: ‘kafka’
)

CREATE [TEMPORARY] TABLE derived_table (
    LIKE base_table,
    WATERMARK FOR tstmp AS tsmp - INTERVAL '5' SECOND
)
LIKE base_table;

Resulting table equivalent to:

...

Code Block
languagesql
CREATE [TEMPORARY] TABLE base_table_1 (
    id BIGINT,
    name STRING,
    tstmp TIMESTAMP,
	PRIMARY KEY(id)
) WITH (
    ‘connector’: ‘kafka’,
    ‘connector.starting-offset’: ‘12345’,
    ‘format’: ‘json’
)

CREATE [TEMPORARY] TABLE basederived_table_2 (
    tstmp TIMESTAMP,
	PRIMARY KEY(tstmp)
) WITH (
    ‘connector’: ‘filesystem’,
    ‘format’: ‘csv’,
    ‘format.delimiter’: ‘\t’   
)

CREATE [TEMPORARY] TABLE derived_table (
    WATERMARK FOR tstmp AS tsmp - INTERVAL '5' SECOND
)
LIKE base_table_1 (
		OVERWRITING OPTIONS),
    LIKE base_table_2 (
		EXCLUDING OPTIONS, 
		EXCLUDING CONSTRAINTS),
    WATERMARK FOR tstmp AS tsmp - INTERVAL '5' SECOND
) WITH (
    ‘connector.starting-offset’: ‘0’
)

...

Code Block
languagesql
CREATE [TEMPORARY] TABLE derived_table (
    id BIGINT,
    name STRING,
	    tstmp TIMESTAMP,
    WATERMARK FOR tstmp AS tsmp - INTERVAL '5' SECOND,
    PRIMARY KEY(id)
) WITH (
    ‘connector’: ‘kafka’,
    ‘connector.starting-offset’: ‘0’,
    ‘format’: ‘json’
)

...

Support of that feature in Table API will require a separate FLIP, as we the connect API requires a rework anyway.

...

It is a new feature with no implication for backwards compatibility.

Rejected Alternatives

Original suggestion was to put the LIKE clause in the schema part. During the discussion it was mentioned that it is a bit weird that a clause in the schema part affects options in the WITH ( /* connector properties */) clause. We moved the LIKE clause out of the schema part.


Originally the suggestion was to allow multiple LIKE clauses. It was suggested to drop that for the first version and support it, if such requirement shows up.