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
Schemainto a final validated representation.- Data types and functions have been expanded to fully qualified identifiers.
- Time attributes are represented in the column's data type.
Expressions have been translated toResolvedExpression.AbstractDataTypes have been translated toDataType.
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<Column> columns, List<WatermarkSpec> watermarkSpecs, UniqueConstraint primaryKey)Deprecated.ResolvedSchema(List<Column> columns, List<WatermarkSpec> watermarkSpecs, UniqueConstraint primaryKey, List<Index> indexes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Optional<Column>getColumn(int columnIndex)Returns theColumninstance for the given column index.Optional<Column>getColumn(String columnName)Returns theColumninstance for the given column name.intgetColumnCount()Returns the number ofColumns of this schema.List<DataType>getColumnDataTypes()Returns all column data types.List<String>getColumnNames()Returns all column names.List<Column>getColumns()Returns allColumns of this schema.List<Index>getIndexes()Returns all table indexes.Optional<UniqueConstraint>getPrimaryKey()Returns the primary key if it has been defined.int[]getPrimaryKeyIndexes()Returns the primary key indexes in thetoPhysicalRowDataType(), if any, otherwise returns an empty array.List<WatermarkSpec>getWatermarkSpecs()Returns a list of watermark specifications each consisting of a rowtime attribute and watermark strategy expression.inthashCode()static ResolvedSchemaof(List<Column> columns)Shortcut for a resolved schema of only columns.static ResolvedSchemaof(Column... columns)Shortcut for a resolved schema of only columns.static ResolvedSchemaphysical(String[] columnNames, DataType[] columnDataTypes)Shortcut for a resolved schema of only physical columns.static ResolvedSchemaphysical(List<String> columnNames, List<DataType> columnDataTypes)Shortcut for a resolved schema of only physical columns.DataTypetoPhysicalRowDataType()Converts all physical columns of this schema into a (possibly nested) row data type.DataTypetoSinkRowDataType()Converts all persisted columns of this schema into a (possibly nested) row data type.DataTypetoSourceRowDataType()Converts all columns of this schema into a (possibly nested) row data type.StringtoString()
-
-
-
Constructor Detail
-
ResolvedSchema
@Deprecated public ResolvedSchema(List<Column> columns, List<WatermarkSpec> watermarkSpecs, @Nullable UniqueConstraint primaryKey)
Deprecated.Please useResolvedSchema(List, List, UniqueConstraint, List)instead.
-
ResolvedSchema
public ResolvedSchema(List<Column> columns, List<WatermarkSpec> watermarkSpecs, @Nullable UniqueConstraint primaryKey, List<Index> indexes)
-
-
Method Detail
-
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 ofColumns 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 theColumninstance for the given column index.- Parameters:
columnIndex- the index of the column
-
getColumn
public Optional<Column> getColumn(String columnName)
Returns theColumninstance 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
WatermarkSpecin 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 in thetoPhysicalRowDataType(), 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.
-
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.
-
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.
-
-