...
Considering the TRUNCATE TABLE statment is useful and widely-used, this FLIP is aimed to support TRUNCATE TABLE statment in Flink. This FLIP will bring Flink the TRUNCATE TABLE
syntax and an interface with which the coresponding connectors can implement their own logic for truncating table.
Public Interfaces
Syntax
We propose add the following syntax for TRUNCATE TABLE statement.
Code Block | ||
---|---|---|
| ||
TRUNCATE TABLE table_name |
It only supports trucate table, if it's a view, it should throw TableException
with message Truncate a view is not support
.
...
Public interfaces Changes
We propose add a inerface for TRUNCATE TABLE statment. The connectors can implement this interface to custom their logic for truncating table.
Code Block | ||
---|---|---|
| ||
/** * Enables to delete all existing data in a {@link DynamicTableSink} table using {@code TRUNCATE * TABLE} statement. * * <p>For {@code TRUNCATE TABLE} statement, if the corresponding {@link DynamicTableSink} have * implemented this interface, then the method {@link #truncateTable()} will be invoked in execution * phase. Otherwise, Flink will throw exception directly. */ @PublicEvolving public interface SupportsTruncate { /** * Execute truncating table. * * @return true if truncate the table successfully otherwise false */ boolean executeTruncation(); } |
...