public static class TableSchema.Builder extends Object
TableSchema
.Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
TableSchema |
build()
Returns a
TableSchema instance. |
TableSchema.Builder |
field(String name,
DataType dataType)
Add a field with name and data type.
|
TableSchema.Builder |
field(String name,
DataType dataType,
String expression)
Add a computed field which is generated by the given expression.
|
TableSchema.Builder |
field(String name,
TypeInformation<?> typeInfo)
Deprecated.
This method will be removed in future versions as it uses the old type system. It
is recommended to use
field(String, DataType) instead which uses the new type
system based on DataTypes . Please make sure to use either the old or the new
type system consistently to avoid unintended behavior. See the website documentation
for more information. |
TableSchema.Builder |
fields(String[] names,
DataType[] dataTypes)
Add an array of fields with names and data types.
|
TableSchema.Builder |
primaryKey(String... columns)
Creates a primary key constraint for a set of given columns.
|
TableSchema.Builder |
primaryKey(String name,
String[] columns)
Creates a primary key constraint for a set of given columns.
|
TableSchema.Builder |
watermark(String rowtimeAttribute,
String watermarkExpressionString,
DataType watermarkExprOutputType)
Specifies the previously defined field as an event-time attribute and specifies the watermark strategy.
|
public TableSchema.Builder field(String name, DataType dataType)
The call order of this method determines the order of fields in the schema.
public TableSchema.Builder field(String name, DataType dataType, String expression)
The call order of this method determines the order of fields in the schema.
name
- Field namedataType
- Field data typeexpression
- Computed column expression, it should be a SQL-style expression whose
identifiers should be all quoted and expanded.
It should be expanded because this expression may be persisted
then deserialized from the catalog, an expanded identifier would
avoid the ambiguity if there are same name UDF referenced from
different paths. For example, if there is a UDF named "my_udf" from
path "my_catalog.my_database", you could pass in an expression like
"`my_catalog`.`my_database`.`my_udf`(`f0`) + 1";
It should be quoted because user could use a reserved keyword as the
identifier, and we have no idea if it is quoted when deserialize from
the catalog, so we force to use quoted identifier here. But framework
will not check whether it is qualified and quoted or not.public TableSchema.Builder fields(String[] names, DataType[] dataTypes)
The call order of this method determines the order of fields in the schema.
@Deprecated public TableSchema.Builder field(String name, TypeInformation<?> typeInfo)
field(String, DataType)
instead which uses the new type
system based on DataTypes
. Please make sure to use either the old or the new
type system consistently to avoid unintended behavior. See the website documentation
for more information.public TableSchema.Builder watermark(String rowtimeAttribute, String watermarkExpressionString, DataType watermarkExprOutputType)
rowtimeAttribute
- the field name as a rowtime attribute, can be a nested field using dot separator.watermarkExpressionString
- the string representation of watermark generation expression,
e.g. "ts - INTERVAL '5' SECOND". The string is a qualified SQL expression
string (UDFs are expanded) but will not be validated by TableSchema
.watermarkExprOutputType
- the data type of the computation result of watermark generation expression.
Whether the data type equals to the output type of expression will also
not be validated by TableSchema
.public TableSchema.Builder primaryKey(String... columns)
The primary key will be assigned a random name.
columns
- array of columns that form a unique primary keypublic TableSchema.Builder primaryKey(String name, String[] columns)
columns
- array of columns that form a unique primary keyname
- name for the primary key, can be used to reference the constraintpublic TableSchema build()
TableSchema
instance.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.