@PublicEvolving public final class ResolvedSchema extends Object
This class is the result of resolving a Schema into a final validated representation.
Expressions have been translated to ResolvedExpression.
AbstractDataTypes have been translated to DataType.
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 and Description |
|---|
ResolvedSchema(List<Column> columns,
List<WatermarkSpec> watermarkSpecs,
UniqueConstraint primaryKey) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
Optional<Column> |
getColumn(int columnIndex)
Returns the
Column instance for the given column index. |
Optional<Column> |
getColumn(String columnName)
Returns the
Column instance for the given column name. |
int |
getColumnCount()
Returns the number of
Columns of this schema. |
List<DataType> |
getColumnDataTypes()
Returns all column data types.
|
List<String> |
getColumnNames()
Returns all column names.
|
List<Column> |
getColumns()
Returns all
Columns of this schema. |
Optional<UniqueConstraint> |
getPrimaryKey()
Returns the primary key if it has been defined.
|
int[] |
getPrimaryKeyIndexes()
Returns the primary key indexes, 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.
|
int |
hashCode() |
static ResolvedSchema |
of(Column... columns)
Shortcut for a resolved schema of only columns.
|
static ResolvedSchema |
of(List<Column> columns)
Shortcut for a resolved schema of only columns.
|
static ResolvedSchema |
physical(List<String> columnNames,
List<DataType> columnDataTypes)
Shortcut for a resolved schema of only physical columns.
|
static ResolvedSchema |
physical(String[] columnNames,
DataType[] columnDataTypes)
Shortcut for a resolved schema of only physical columns.
|
DataType |
toPhysicalRowDataType()
Converts all physical columns of this schema into a (possibly nested) row data type.
|
DataType |
toSinkRowDataType()
Converts all persisted columns of this schema into a (possibly nested) row data type.
|
DataType |
toSourceRowDataType()
Converts all columns of this schema into a (possibly nested) row data type.
|
String |
toString() |
public ResolvedSchema(List<Column> columns, List<WatermarkSpec> watermarkSpecs, @Nullable UniqueConstraint primaryKey)
public static ResolvedSchema of(List<Column> columns)
public static ResolvedSchema of(Column... columns)
public static ResolvedSchema physical(List<String> columnNames, List<DataType> columnDataTypes)
public static ResolvedSchema physical(String[] columnNames, DataType[] columnDataTypes)
public int getColumnCount()
Columns of this schema.public List<String> getColumnNames()
public List<DataType> getColumnDataTypes()
public Optional<Column> getColumn(int columnIndex)
Column instance for the given column index.columnIndex - the index of the columnpublic Optional<Column> getColumn(String columnName)
Column instance for the given column name.columnName - the name of the columnpublic List<WatermarkSpec> getWatermarkSpecs()
Note: Currently, there is at most one WatermarkSpec in the list, because we don't
support multiple watermark definitions yet.
public Optional<UniqueConstraint> getPrimaryKey()
public int[] getPrimaryKeyIndexes()
public DataType toSourceRowDataType()
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.
public DataType toPhysicalRowDataType()
Note: The returned row data type contains only physical columns. It does not include computed or metadata columns.
public DataType toSinkRowDataType()
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.
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.