This documentation is for an unreleased version of Apache Paimon. We recommend you use the latest stable version.
Default Value
Default Value #
Paimon allows specifying default values for columns. When users write to these tables without explicitly providing values for certain columns, Paimon automatically generates default values for these columns.
Create Table #
Flink SQL does not have native support for default values, so we can only create a table without default values:
CREATE TABLE my_table (
a BIGINT,
b STRING,
c INT
);
We support the procedure of modifying column default values in Flink. You can add default value definitions after creating the table:
CALL sys.alter_column_default_value('default.my_table', 'b', 'my_value');
CALL sys.alter_column_default_value('default.my_table', 'c', '5');
Insert Table #
For SQL commands that execute table writes, such as the INSERT
, UPDATE
, and MERGE
commands, NULL
value is
parsed into the default value specified for the corresponding column.
For example:
INSERT INTO my_table (a) VALUES (1), (2);
SELECT * FROM my_table;
-- result: [[1, 5, my_value], [2, 5, my_value]]