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 Details

  • Method Details

    • of

      public static ResolvedSchema of(List<Column> columns)
      Shortcut for a resolved schema of only columns.
    • of

      public static ResolvedSchema of(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<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<Column> getColumn(int columnIndex)
      Returns the Column instance for the given column index.
      Parameters:
      columnIndex - the index of the column
    • getColumn

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

      public List<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<UniqueConstraint> getPrimaryKey()
      Returns the primary key if it has been defined.
    • getPrimaryKeyIndexes

      public int[] getPrimaryKeyIndexes()
      Returns the primary key indexes, 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