Class SqlTableLike

  • All Implemented Interfaces:
    Cloneable, ExtendedSqlNode

    public class SqlTableLike
    extends org.apache.calcite.sql.SqlCall
    implements ExtendedSqlNode
    A LIKE clause in a CREATE TABLE statement.

    It enables to use an existing table descriptor to define a new, adjusted/extended table. Users can control the way particular features of both declarations are merged using SqlTableLike.MergingStrategy and SqlTableLike.FeatureOption.

    Example: A DDL like the one below for creating a `derived_table`

    
     CREATE 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 derived_table (
         WATERMARK FOR tstmp AS tsmp - INTERVAL '5' SECOND
     )
     WITH (
         ‘connector.starting-offset’: ‘0’
     )
     LIKE base_table (
       OVERWRITING OPTIONS,
       EXCLUDING CONSTRAINTS
     )
     

    is equivalent to:

    
     CREATE TEMPORARY TABLE derived_table (
         id BIGINT,
         name STRING,
         tstmp TIMESTAMP,
         WATERMARK FOR tstmp AS tsmp - INTERVAL '5' SECOND
     ) WITH (
         ‘connector’: ‘kafka’,
         ‘connector.starting-offset’: ‘0’,
         ‘format’: ‘json’
     )
     
    • Constructor Detail

      • SqlTableLike

        public SqlTableLike​(org.apache.calcite.sql.parser.SqlParserPos pos,
                            org.apache.calcite.sql.SqlIdentifier sourceTable,
                            List<SqlTableLike.SqlTableLikeOption> options)
    • Method Detail

      • getOperator

        @Nonnull
        public org.apache.calcite.sql.SqlOperator getOperator()
        Specified by:
        getOperator in class org.apache.calcite.sql.SqlCall
      • getOperandList

        @Nonnull
        public List<org.apache.calcite.sql.SqlNode> getOperandList()
        Specified by:
        getOperandList in class org.apache.calcite.sql.SqlCall
      • getSourceTable

        public org.apache.calcite.sql.SqlIdentifier getSourceTable()
      • unparse

        public void unparse​(org.apache.calcite.sql.SqlWriter writer,
                            int leftPrec,
                            int rightPrec)
        Overrides:
        unparse in class org.apache.calcite.sql.SqlCall