Class ResolvedSchema

java.lang.Object
org.apache.flink.table.catalog.ResolvedSchema

@PublicEvolving public final class ResolvedSchema extends Object
Schema of a table or view consisting of columns, constraints, and watermark specifications.

This class is the result of resolving a Schema into a final validated representation.

This class should not be passed into a connector. It is therefore also not serializable. Instead, the toPhysicalRowDataType() can be passed around where necessary.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ResolvedSchema(List<org.apache.flink.table.catalog.Column> columns, List<org.apache.flink.table.catalog.WatermarkSpec> watermarkSpecs, org.apache.flink.table.catalog.UniqueConstraint primaryKey)
    Deprecated.
    ResolvedSchema(List<org.apache.flink.table.catalog.Column> columns, List<org.apache.flink.table.catalog.WatermarkSpec> watermarkSpecs, org.apache.flink.table.catalog.UniqueConstraint primaryKey, List<org.apache.flink.table.catalog.Index> indexes)
     
    ResolvedSchema(List<org.apache.flink.table.catalog.Column> columns, List<org.apache.flink.table.catalog.WatermarkSpec> watermarkSpecs, org.apache.flink.table.catalog.UniqueConstraint primaryKey, List<org.apache.flink.table.catalog.Index> indexes, org.apache.flink.table.catalog.ImmutableColumnsConstraint immutableColumns)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Optional<org.apache.flink.table.catalog.Column>
    getColumn(int columnIndex)
    Returns the Column instance for the given column index.
    Optional<org.apache.flink.table.catalog.Column>
    getColumn(String columnName)
    Returns the Column instance for the given column name.
    int
    Returns the number of Columns of this schema.
    Returns all column data types.
    Returns all column names.
    List<org.apache.flink.table.catalog.Column>
    Returns all Columns of this schema.
    int[]
    Returns the indexes of columns about the immutable constraint in the toPhysicalRowDataType(), if any, otherwise returns an empty array.
    Optional<org.apache.flink.table.catalog.ImmutableColumnsConstraint>
    Returns the constraint about immutable columns if it has been defined.
    List<org.apache.flink.table.catalog.Index>
    Returns all table indexes.
    Optional<org.apache.flink.table.catalog.UniqueConstraint>
    Returns the primary key if it has been defined.
    int[]
    Returns the primary key indexes in the toPhysicalRowDataType(), if any, otherwise returns an empty array.
    List<org.apache.flink.table.catalog.WatermarkSpec>
    Returns a list of watermark specifications each consisting of a rowtime attribute and watermark strategy expression.
    int
     
    of(List<org.apache.flink.table.catalog.Column> columns)
    Shortcut for a resolved schema of only columns.
    of(org.apache.flink.table.catalog.Column... columns)
    Shortcut for a resolved schema of only columns.
    physical(String[] columnNames, DataType[] columnDataTypes)
    Shortcut for a resolved schema of only physical columns.
    physical(List<String> columnNames, List<DataType> columnDataTypes)
    Shortcut for a resolved schema of only physical columns.
    Converts all physical columns of this schema into a (possibly nested) row data type.
    Converts all persisted columns of this schema into a (possibly nested) row data type.
    Converts all columns of this schema into a (possibly nested) row data type.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ResolvedSchema

      @Deprecated public ResolvedSchema(List<org.apache.flink.table.catalog.Column> columns, List<org.apache.flink.table.catalog.WatermarkSpec> watermarkSpecs, @Nullable org.apache.flink.table.catalog.UniqueConstraint primaryKey)
      Deprecated.
    • ResolvedSchema

      public ResolvedSchema(List<org.apache.flink.table.catalog.Column> columns, List<org.apache.flink.table.catalog.WatermarkSpec> watermarkSpecs, @Nullable org.apache.flink.table.catalog.UniqueConstraint primaryKey, List<org.apache.flink.table.catalog.Index> indexes)
    • ResolvedSchema

      public ResolvedSchema(List<org.apache.flink.table.catalog.Column> columns, List<org.apache.flink.table.catalog.WatermarkSpec> watermarkSpecs, @Nullable org.apache.flink.table.catalog.UniqueConstraint primaryKey, List<org.apache.flink.table.catalog.Index> indexes, @Nullable org.apache.flink.table.catalog.ImmutableColumnsConstraint immutableColumns)
  • Method Details

    • of

      public static ResolvedSchema of(List<org.apache.flink.table.catalog.Column> columns)
      Shortcut for a resolved schema of only columns.
    • of

      public static ResolvedSchema of(org.apache.flink.table.catalog.Column... columns)
      Shortcut for a resolved schema of only columns.
    • physical

      public static ResolvedSchema physical(List<String> columnNames, List<DataType> columnDataTypes)
      Shortcut for a resolved schema of only physical columns.
    • physical

      public static ResolvedSchema physical(String[] columnNames, DataType[] columnDataTypes)
      Shortcut for a resolved schema of only physical columns.
    • getColumnCount

      public int getColumnCount()
      Returns the number of Columns of this schema.
    • getColumns

      public List<org.apache.flink.table.catalog.Column> getColumns()
      Returns all Columns of this schema.
    • getColumnNames

      public List<String> getColumnNames()
      Returns all column names. It does not distinguish between different kinds of columns.
    • getColumnDataTypes

      public List<DataType> getColumnDataTypes()
      Returns all column data types. It does not distinguish between different kinds of columns.
    • getColumn

      public Optional<org.apache.flink.table.catalog.Column> getColumn(int columnIndex)
      Returns the Column instance for the given column index.
      Parameters:
      columnIndex - the index of the column
    • getColumn

      public Optional<org.apache.flink.table.catalog.Column> getColumn(String columnName)
      Returns the Column instance for the given column name.
      Parameters:
      columnName - the name of the column
    • getWatermarkSpecs

      public List<org.apache.flink.table.catalog.WatermarkSpec> getWatermarkSpecs()
      Returns a list of watermark specifications each consisting of a rowtime attribute and watermark strategy expression.

      Note: Currently, there is at most one WatermarkSpec in the list, because we don't support multiple watermark definitions yet.

    • getPrimaryKey

      public Optional<org.apache.flink.table.catalog.UniqueConstraint> getPrimaryKey()
      Returns the primary key if it has been defined.
    • getIndexes

      public List<org.apache.flink.table.catalog.Index> getIndexes()
      Returns all table indexes.
    • getImmutableColumns

      public Optional<org.apache.flink.table.catalog.ImmutableColumnsConstraint> getImmutableColumns()
      Returns the constraint about immutable columns if it has been defined.
    • getPrimaryKeyIndexes

      public int[] getPrimaryKeyIndexes()
      Returns the primary key indexes in the toPhysicalRowDataType(), if any, otherwise returns an empty array.
    • getImmutableColumnIndexes

      public int[] getImmutableColumnIndexes()
      Returns the indexes of columns about the immutable constraint in the toPhysicalRowDataType(), if any, otherwise returns an empty array.
    • toSourceRowDataType

      public DataType toSourceRowDataType()
      Converts all columns of this schema into a (possibly nested) row data type.

      This method returns the source-to-query schema.

      Note: The returned row data type contains physical, computed, and metadata columns. Be careful when using this method in a table source or table sink. In many cases, toPhysicalRowDataType() might be more appropriate.

      See Also:
    • toPhysicalRowDataType

      public DataType toPhysicalRowDataType()
      Converts all physical columns of this schema into a (possibly nested) row data type.

      Note: The returned row data type contains only physical columns. It does not include computed or metadata columns.

      See Also:
    • toSinkRowDataType

      public DataType toSinkRowDataType()
      Converts all persisted columns of this schema into a (possibly nested) row data type.

      This method returns the query-to-sink schema.

      Note: Computed columns and virtual columns are excluded in the returned row data type. The data type contains the columns of toPhysicalRowDataType() plus persisted metadata columns.

      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object