Package org.apache.flink.table.utils
Class TableSchemaUtils
- java.lang.Object
-
- org.apache.flink.table.utils.TableSchemaUtils
-
@Internal public class TableSchemaUtils extends Object
Utilities toTableSchema
.
-
-
Constructor Summary
Constructors Constructor Description TableSchemaUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TableSchema.Builder
builderWithGivenSchema(TableSchema oriSchema)
Creates a builder with given table schema.static TableSchema
checkOnlyPhysicalColumns(TableSchema schema)
Throws an exception if the givenTableSchema
contains any non-physical columns.static boolean
containsPhysicalColumnsOnly(TableSchema schema)
Returns true if there are only physical columns in the givenTableSchema
.static TableSchema
dropConstraint(TableSchema oriSchema, String constraintName)
Creates a new schema but drop the constraint with given name.static TableSchema
getPersistedSchema(TableSchema tableSchema)
ReturnTableSchema
which consists of all persisted columns.static TableSchema
getPhysicalSchema(TableSchema tableSchema)
ReturnTableSchema
which consists of all physical columns.static int[]
getPrimaryKeyIndices(TableSchema schema)
Returns the field indices of primary key in the physical columns of this schema (not include computed columns or metadata columns).static ResolvedSchema
removeTimeAttributeFromResolvedSchema(ResolvedSchema resolvedSchema)
Removes time attributes from theResolvedSchema
.
-
-
-
Method Detail
-
getPhysicalSchema
public static TableSchema getPhysicalSchema(TableSchema tableSchema)
ReturnTableSchema
which consists of all physical columns. That means, the computed columns and metadata columns are filtered out.Readers(or writers) such as
TableSource
andTableSink
should use this physical schema to generateTableSource.getProducedDataType()
andTableSource.getTableSchema()
rather than using the raw TableSchema which may contains additional columns.
-
getPersistedSchema
public static TableSchema getPersistedSchema(TableSchema tableSchema)
ReturnTableSchema
which consists of all persisted columns. That means, the virtual computed columns and metadata columns are filtered out.Its difference from
getPhysicalSchema(TableSchema)
is that it includes of all physical columns and metadata columns without virtual keyword.
-
containsPhysicalColumnsOnly
public static boolean containsPhysicalColumnsOnly(TableSchema schema)
Returns true if there are only physical columns in the givenTableSchema
.
-
checkOnlyPhysicalColumns
public static TableSchema checkOnlyPhysicalColumns(TableSchema schema)
Throws an exception if the givenTableSchema
contains any non-physical columns.
-
getPrimaryKeyIndices
public static int[] getPrimaryKeyIndices(TableSchema schema)
Returns the field indices of primary key in the physical columns of this schema (not include computed columns or metadata columns).
-
removeTimeAttributeFromResolvedSchema
public static ResolvedSchema removeTimeAttributeFromResolvedSchema(ResolvedSchema resolvedSchema)
Removes time attributes from theResolvedSchema
.
-
builderWithGivenSchema
public static TableSchema.Builder builderWithGivenSchema(TableSchema oriSchema)
Creates a builder with given table schema.- Parameters:
oriSchema
- Original schema- Returns:
- the builder with all the information from the given schema
-
dropConstraint
public static TableSchema dropConstraint(TableSchema oriSchema, String constraintName)
Creates a new schema but drop the constraint with given name.
-
-