Class SqlTableLike

java.lang.Object
org.apache.calcite.sql.SqlNode
org.apache.calcite.sql.SqlCall
org.apache.flink.sql.parser.ddl.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’
 )
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    A feature of a table descriptor that will be merged into the new table.
    static enum 
    A strategy that describes how the features of the parent source table should be merged with the features of the newly created table.
    static class 
  • Field Summary

    Fields inherited from class org.apache.calcite.sql.SqlNode

    EMPTY_ARRAY, pos
  • Constructor Summary

    Constructors
    Constructor
    Description
    SqlTableLike(org.apache.calcite.sql.parser.SqlParserPos pos, org.apache.calcite.sql.SqlIdentifier sourceTable, List<SqlTableLike.SqlTableLikeOption> options)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.apache.calcite.sql.SqlNode>
     
    org.apache.calcite.sql.SqlOperator
     
     
    org.apache.calcite.sql.SqlIdentifier
     
    void
    unparse(org.apache.calcite.sql.SqlWriter writer, int leftPrec, int rightPrec)
     
    void
     

    Methods inherited from class org.apache.calcite.sql.SqlCall

    accept, clone, equalsDeep, findValidOptions, getCallSignature, getFunctionQuantifier, getKind, getMonotonicity, isCountStar, isExpanded, operand, operandCount, setOperand, validate

    Methods inherited from class org.apache.calcite.sql.SqlNode

    clone, clone, cloneArray, equalDeep, equalDeep, equalsDeep, getParserPosition, isA, toList, toList, toSqlString, toSqlString, toSqlString, toString, unparseWithParentheses, validateExpr

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SqlTableLike

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

    • 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()
    • getOptions

      public List<SqlTableLike.SqlTableLikeOption> getOptions()
    • validate

      public void validate() throws SqlValidateException
      Specified by:
      validate in interface ExtendedSqlNode
      Throws:
      SqlValidateException
    • unparse

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