Class Schema.Builder
- java.lang.Object
-
- org.apache.flink.cdc.common.schema.Schema.Builder
-
- Enclosing class:
- Schema
@PublicEvolving public static final class Schema.Builder extends Object
A builder for constructing an immutable but still unresolvedSchema.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Schemabuild()Returns an instance of aSchema.Schema.Buildercolumn(Column column)Schema.Buildercomment(String comment)Declares table comment.Schema.BuilderfromRowDataType(DataType type)Adopts all fields of the given row as physical columns of the schema.Schema.BuildermetadataColumn(String columnName, DataType type)Declares a metadata column that is appended to this schema.Schema.BuildermetadataColumn(String columnName, DataType type, String metadataKey)Declares a metadata column that is appended to this schema.Schema.BuildermetadataColumn(String columnName, DataType type, String metadataKey, String comment)Declares a metadata column that is appended to this schema.Schema.Builderoption(String key, String value)Declares an option.Schema.Builderoptions(Map<String,String> options)Declares options.Schema.BuilderpartitionKey(String... columnNames)Declares a partition key constraint for a set of given columns.Schema.BuilderpartitionKey(List<String> columnNames)Declares a partition key constraint for a set of given columns.Schema.BuilderphysicalColumn(String columnName, DataType type)Declares a physical column that is appended to this schema.Schema.BuilderphysicalColumn(String columnName, DataType type, String comment)Declares a physical column that is appended to this schema.Schema.BuilderphysicalColumn(String columnName, DataType type, String comment, String defaultValue)Declares a physical column that is appended to this schema.Schema.BuilderprimaryKey(String... columnNames)Declares a primary key constraint for a set of given columns.Schema.BuilderprimaryKey(List<String> columnNames)Declares a primary key constraint for a set of given columns.Schema.BuildersetColumns(List<Column> columns)Set new columns.
-
-
-
Method Detail
-
partitionKey
public Schema.Builder partitionKey(String... columnNames)
Declares a partition key constraint for a set of given columns. Partition key uniquely identify a row in a table. Neither of columns in a partition can be nullable.- Parameters:
columnNames- columns that form a unique primary key
-
partitionKey
public Schema.Builder partitionKey(List<String> columnNames)
Declares a partition key constraint for a set of given columns. Partition key uniquely identify a row in a table. Neither of columns in a partition can be nullable.- Parameters:
columnNames- columns that form a unique primary key
-
fromRowDataType
public Schema.Builder fromRowDataType(DataType type)
Adopts all fields of the given row as physical columns of the schema.
-
physicalColumn
public Schema.Builder physicalColumn(String columnName, DataType type)
Declares a physical column that is appended to this schema.- Parameters:
columnName- column nametype- data type of the column
-
physicalColumn
public Schema.Builder physicalColumn(String columnName, DataType type, String comment)
Declares a physical column that is appended to this schema.- Parameters:
columnName- column nametype- data type of the columncomment- description of the column
-
physicalColumn
public Schema.Builder physicalColumn(String columnName, DataType type, String comment, String defaultValue)
Declares a physical column that is appended to this schema.- Parameters:
columnName- column nametype- data type of the columncomment- description of the columndefaultValue- default value of the column
-
metadataColumn
public Schema.Builder metadataColumn(String columnName, DataType type)
Declares a metadata column that is appended to this schema.- Parameters:
columnName- column nametype- data type of the column
-
metadataColumn
public Schema.Builder metadataColumn(String columnName, DataType type, String metadataKey)
Declares a metadata column that is appended to this schema.- Parameters:
columnName- column nametype- data type of the columnmetadataKey- the key of metadata
-
metadataColumn
public Schema.Builder metadataColumn(String columnName, DataType type, String metadataKey, String comment)
Declares a metadata column that is appended to this schema.- Parameters:
columnName- column nametype- data type of the columnmetadataKey- the key of metadatacomment- description of the column
-
column
public Schema.Builder column(Column column)
-
primaryKey
public Schema.Builder primaryKey(String... columnNames)
Declares a primary key constraint for a set of given columns. Primary key uniquely identify a row in a table. Neither of columns in a primary can be nullable.- Parameters:
columnNames- columns that form a unique primary key
-
primaryKey
public Schema.Builder primaryKey(List<String> columnNames)
Declares a primary key constraint for a set of given columns. Primary key uniquely identify a row in a table. Neither of columns in a primary can be nullable.- Parameters:
columnNames- columns that form a unique primary key
-
options
public Schema.Builder options(Map<String,String> options)
Declares options.
-
option
public Schema.Builder option(String key, String value)
Declares an option.
-
comment
public Schema.Builder comment(String comment)
Declares table comment.
-
setColumns
public Schema.Builder setColumns(List<Column> columns)
Set new columns.
-
-