T
- Type of records that this TableSink
expects and supports.@PublicEvolving public interface UpsertStreamTableSink<T> extends StreamTableSink<Tuple2<Boolean,T>>
TableSink
to emit a streaming Table
with insert, update, and
delete changes. The Table
must be have unique key fields (atomic or composite) or be
append-only.
If the Table
does not have a unique key and is not append-only, a TableException
will be thrown.
The unique key of the table is configured by the setKeyFields(String[])
method.
The Table
will be converted into a stream of upsert and delete messages which are
encoded as Tuple2
. The first field is a Boolean
flag to indicate the message
type. The second field holds the record of the requested type T
.
A message with true Boolean
field is an upsert message for the configured key.
A message with false flag is a delete message for the configured key.
If the table is append-only, all messages will have a true flag and must be interpreted as insertions.
Modifier and Type | Method and Description |
---|---|
default TypeInformation<Tuple2<Boolean,T>> |
getOutputType() |
TypeInformation<T> |
getRecordType()
Returns the requested record type.
|
void |
setIsAppendOnly(Boolean isAppendOnly)
Specifies whether the
Table to write is append-only or not. |
void |
setKeyFields(String[] keys)
Configures the unique key fields of the
Table to write. |
consumeDataStream
configure, getConsumedDataType, getFieldNames, getFieldTypes, getTableSchema
void setKeyFields(String[] keys)
Table
to write. The method is called after
TableSink.configure(String[], TypeInformation[])
.
The keys array might be empty, if the table consists of a single (updated) record. If the table does not have a key and is append-only, the keys attribute is null.
keys
- the field names of the table's keys, an empty array if the table has a single
row, and null if the table is append-only and has no key.void setIsAppendOnly(Boolean isAppendOnly)
Table
to write is append-only or not.isAppendOnly
- true if the table is append-only, false otherwise.TypeInformation<T> getRecordType()
default TypeInformation<Tuple2<Boolean,T>> getOutputType()
getOutputType
in interface TableSink<Tuple2<Boolean,T>>
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.