paimon icon indicating copy to clipboard operation
paimon copied to clipboard

[Bug] Not Support DATE type for partition fields

Open BaoHuaWang opened this issue 3 weeks ago • 2 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Paimon version

CREATE TABLE IF NOT EXISTS paimon_catalog.soc.fw_error_log ( dt DATE COMMENT '日期分区', deviceSn STRING COMMENT '设备SN', logType STRING COMMENT '日志类型', msg STRING COMMENT '原始数据', insertTime TIMESTAMP COMMENT '插入时间' ) PARTITIONED BY (dt) WITH ( -- 表类型:追加表,只新增无更新 'table-type' = 'append-table',

-- Parquet 文件配置
'file.format' = 'parquet',
'file.compression' = 'zstd',
'file.compression.zstd-level' = '3',
'target-file-size' = '256mb',
-- 分桶:租户ID + 设备SN(驼峰字段对齐)
'bucket' = '12',
'bucket-key' = 'deviceSn',

-- 分区TTL:365天自动清理过期分区
'partition.legacy-name' = 'false',
'partition.expiration-strategy' = 'values-time',
'partition.expiration-time' = '90d',
'partition.expiration-check-interval' = '4h',
'partition.timestamp-formatter' = 'yyyy-MM-dd',
'partition.timestamp-pattern' = '$dt',

-- 快照保留策略
'snapshot.time-retained' = '7d',
'snapshot.num-retained.min' = '50',
'snapshot.num-retained.max' = '60',
'snapshot.clean-empty-directories' = 'true',
'snapshot.expire.execution-mode'='async',

);

Compute Engine

flink

Minimal reproduce step

flink-sql

What doesn't meet your expectations?

not

Anything else?

not

Are you willing to submit a PR?

  • [x] #11143

BaoHuaWang avatar Nov 13 '26 08:11 BaoHuaWang

Paimon version: 1.4.2

Compute Engine: Flink 1.19 (flink-sql)

Minimal reproduce step: CREATE TABLE t (id INT, dt DATE) PARTITIONED BY (dt) WITH ( 'connector' = 'paimon', 'path' = '...', 'partition.expiration-time' = '7 d', 'partition.expiration-check-interval' = '1 min' ); INSERT INTO t VALUES (1, DATE '2020-01-01'); -- wait for the expiration check

What doesn't meet your expectations? The old partition is never expired. The JM/TM log shows: "Can't extract datetime from partition dt:18262." PartitionTimeExtractor stringifies the DATE partition value (days since epoch, e.g. 18262) and fails to parse it as a date, so PartitionValuesTimePredicate#test always returns false. Expected: DATE-typed partition fields should be recognized and expired correctly.

Anything else? Also fails with 'partition.timestamp-pattern' = '$dt', and with 'partition.timestamp-format.strict' = 'true' the write itself throws "Partition dt:18262 does not match the 'partition.timestamp-formatter'".

BaoHuaWang avatar Nov 13 '26 09:11 BaoHuaWang

Thanks for the Flink 1.19 example. The 18262 in the warning is 2020-01-01 expressed as days since the Unix epoch. In Paimon 1.4.2, values-time passes that integer to the date parser, which explains why the partition is skipped.

I reproduced this on Flink 1.19.3 with Paimon 1.4.2. With a seven-day retention period, a second batch insert triggered the expiry check. The new row was visible, but the 2020-01-01 partition was still readable, and the TaskManager logged Can't extract datetime from partition dt:18262. SQL output and TaskManager log

#10464 fixes this on master. I checked the 2.0.0 and 2.1.0 release tags too, and both still have the old conversion. Is a backport planned for a release that supports Flink 1.19?

skyyyy955 avatar Nov 18 '26 15:11 skyyyy955