Updated on 2026-06-27 GMT+08:00

Creating a Paimon Append-Only Table

Scenarios

If a table does not have a primary key defined, it is an append-only table by default. Compared to the primary key table, an append-only table does not have the ability to directly receive changelogs. It can only receive incoming data from append operations. This type of table is suitable for use cases that do not require streaming updates.

Syntax Structure

For example, create an append-only table with the partition key pt.

-- SPARK SQL
CREATE TABLE my_table (
    id  INT,
    a  STRING,
    pt STRING
) TBLPROPERTIES (
    'bucket' = '4'
);

Append-Only Table Types

Table 1 Append-only table types

Type

Definition

Description

Standard Append table (default)

When creating a Paimon append-only table, do not specify a bucket or specify 'bucket' = '-1'.

There is no concept of a bucket. Similar to Hive tables, data files are organized by partition, data can be sorted, and write speeds are faster. Automatic merging of small files is supported. You can also disable automatic merging by setting write-only=true and use an independent compaction task for compression.

The read order may not be the same as the write order in streaming mode. It is suitable for scenarios where there are no requirements for the data streaming order.

Bucketed append table

When creating a Paimon append-only table, you can set 'bucket' = '<num>' to define the number of buckets. For a non-partitioned table, this sets the total number of buckets to <num>, while for a partitioned table, it defines the number of buckets (<num>) per individual partition. <num> is an integer greater than 0.

By default, the bucket to which each data record belongs is determined by the values of all columns in the data. You can modify the bucketing method by specifying the bucket-key parameter. For example, if 'bucket-key' = 'c1,c2' is configured, Paimon determines the bucket to which each data record belongs based on the values of columns c1 and c2.

In streaming mode, records in each bucket are produced in the same order in which data is written to the Paimon table. Specifically:

  • For any two records from two different partitions, if 'scan.plan-sort-partition' = 'true' is configured, the record with a smaller partition value will be produced first. Otherwise, the record with an earlier partition creation time will be produced first.
  • For any two records from the same partition and the same bucket, the first written record will be produced first.
  • For any two records from the same partition but two different buckets, different buckets are processed by different tasks, there is no order guarantee between them.