Skip to content

[spark] Do not match timestamp partitions by truncating extra digits - #11524

Open
arimu1 wants to merge 1 commit into
apache:masterfrom
arimu1:fix/11514-timestamp-partition-spec
Open

arimu1 wants to merge 1 commit into
apache:masterfrom
arimu1:fix/11514-timestamp-partition-spec

Conversation

@arimu1

@arimu1 arimu1 commented Nov 29, 2026 •

Copy link
Copy Markdown

Purpose

Fixes #11514.

TRUNCATE PARTITION and a partial DROP PARTITION converted Spark timestamp specs with DateTimeUtils.truncate, so extra digits that a TIMESTAMP(3) (or TIMESTAMP_LTZ(3)) column cannot store still selected the truncated partition. Example: ts = '2026-01-01 10:00:00.123999' removed the stored ts = .123 partition.

A spec is now kept only when the timestamp is already equal at the column's precision. Trailing zeros still match, because Spark holds microseconds. A full DROP PARTITION that names every partition column already threw NoSuchPartitionsException; a partial spec no longer matches by truncating those extra digits.

This does not change Data Evolution (#11513) or the Spark 4.2 DESCRIBE ... PARTITION work in #11419.

Tests

  • PaimonPartitionManagementTest: extra digits do not truncate a TIMESTAMP(3) or TIMESTAMP_LTZ(3) partition; a matching millisecond spec still does.
  • Same class: a partial DROP PARTITION with extra digits leaves every (ts, p) partition; a full spec still throws NoSuchPartitionsException; a matching prefix still drops the intended partitions.
JAVA_HOME=<Temurin 21> mvn -pl paimon-spark/paimon-spark-ut -Pfast-build -Pspark3 \
  -DfailIfNoTests=false \
  -DwildcardSuites=org.apache.paimon.spark.sql.PaimonPartitionManagementTest \
  -Dtest=none \
  test

28 tests, 0 failed (Spark 3.5.9).

A TIMESTAMP(3) spec such as ts='...123999' is not equal at millisecond
precision, so TRUNCATE PARTITION and a partial DROP PARTITION must not
select the stored .123 partition.

Fixes apache#11514.

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [spark] TRUNCATE PARTITION and partial DROP PARTITION remove a timestamp partition the spec does not name

1 participant