Skip to content

[core] Support more timestamp types in merge_map_with_keytime - #11031

Open
PyRSA wants to merge 13 commits into
apache:masterfrom
PyRSA:feature/merge-map-with-keytime-more-types
Open

PyRSA wants to merge 13 commits into
apache:masterfrom
PyRSA:feature/merge-map-with-keytime-more-types

Conversation

@PyRSA

@PyRSA PyRSA commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Purpose

This PR extends the supported timestamp field types in merge_map_with_keytime.

The following types are supported:

  • CHAR / VARCHAR
  • TINYINT / SMALLINT / INTEGER / BIGINT
  • DATE / TIME
  • DECIMAL
  • TIMESTAMP
  • TIMESTAMP_LTZ

Character timestamp fields retain Java String.compareTo ordering semantics. The Python implementation is also aligned with the Java behavior.

Tests

  • Add Java tests for supported timestamp types and comparison behavior.
  • Add Python tests for supported timestamp types and comparison behavior.
  • Verify that newer timestamps replace existing values, while equal or older timestamps do not.
  • git diff --check

@Akash3121 Akash3121 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typed timestamp extension is useful for epoch and timestamp fields. The head passed 119 Java tests and 167 Python tests. It conflicts with master after #11043 in the Java aggregator/factory/tests and the Python aggregator. Please preserve merge-map.overwrite-on-equal-ts for both string and typed comparisons when rebasing.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A second interoperability check for the newly supported timestamp precision.

@PyRSA
PyRSA force-pushed the feature/merge-map-with-keytime-more-types branch 7 times, most recently from 860ec82 to 77d3fa4 Compare November 11, 2026 13:31

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requirement fit: SUPPORTED. Implementation: FINDINGS. DECIMAL extends the Java types supported after #11084, and the public Python nanosecond-read fix has real correctness value. The previous DOUBLE and TIMESTAMP(9)/TIMESTAMP_LTZ(9) examples now pass, and overwrite-on-equal behavior is preserved.

Reviewed all eleven files, generic row conversion, Java/Python comparison and native routing. 128 Java field-aggregator tests and 194 Python tests passed. Two additional Java table probes passed normal verify: DECIMAL precision10/25, actual writes, reopened reads, equal-timestamp policy and compaction. Additional real filesystem probes reproduce two remaining compatibility/interop problems below: three exact-baseline legacy controls succeed but current readers fail, and native/Python readers choose different string-timestamp winners. The native probe uses Python planning and omits only scheduling kwargs unsupported by the installed Rust0.4 wheel; Python read fallback is forbidden. Current public Rust main independently still uses the same UTF-8 string comparison. Project flake8 and diff whitespace checks passed.

@PyRSA
PyRSA force-pushed the feature/merge-map-with-keytime-more-types branch from 6e5cd5b to 472f557 Compare November 13, 2026 14:56

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requirement fit: SUPPORTED. Implementation: FINDINGS.

The previous legacy Python BINARY/VARBINARY/BOOLEAN compatibility and public nanosecond-read issues are fixed. 133 Java tests and 203 Python tests passed (122 Python subtests), as did eight real Parquet DECIMAL table probes across aggregation/partial-update, overwrite policy and compaction. Normal Maven checks, project flake8 and git diff --check passed.

Two Native entry paths still disagree with the new UTF-16 comparison. I independently reproduced the native-writer issue, and additionally read the exact Java-written partial-update table through Native with Python fallback forbidden. Exact-baseline and ASCII controls support the regression; details are inline. Probes use supported Python 3.11 / PyArrow 22 / Rust 0.5.0.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requirement fit: SUPPORTED. Implementation: FINDINGS. DECIMAL ordering has a useful persisted-table use case, and the historical Java UTF-16 string behavior is restored. The previously reported ordinary Native writer and Java-written partial-update reader cases are addressed on this head. Three remaining P2 issues are detailed inline.

Validation on this exact head: 201 Java aggregation/partial-update tests and 208 Python tests passed. Eight real Parquet DECIMAL table probes passed across compact/wide DECIMAL, aggregation/partial-update sequence groups, both equal-timestamp policies, multiple commits, compaction and reopening. A real Java-written Unicode partial-update table now fails explicitly before Native opens. Explicitly enabled Rust 0.5 batch writer/read probes preserve the UTF-16 winner with both field-specific and default aggregator options. Additional real Native probes reproduce the MERGE source mismatch and the effective-aggregator false positive. The exact merge-base control agrees across both MERGE source forms.

Normal Maven checks and git diff --check passed. Changed-file project flake8 fails with the same E123 that stops the Python jobs in CI43866912063; therefore the PR is not CI-green. The separate Spark 3 job stopped resolving a Maven plugin dependency, which I have not attributed to this diff. No production source changes were made.

@PyRSA

PyRSA commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@JingsongLi Thanks for the detailed reviews and the end-to-end reproductions. They have helped uncover several issues that were not covered by the existing tests.

Would you be willing to actively contribute to the implementation of this PR and its Rust counterpart (apache/paimon-rust#1378), particularly around Native integration and cross-language compatibility?

Some of the underlying Native/Rust execution paths are quite complex, and your experience would be extremely valuable. I'd really appreciate your help in working through these areas, including making code changes directly where appropriate.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requirement fit: SUPPORTED. Implementation: FINDINGS.

Rechecked unchanged 3d866cafc3: the existing Native MERGE source, sequence-group effective-aggregator and E123 lint findings remain. Normal Maven checks pass 198 Java aggregation/partial-update tests; 208 Python tests pass. Eight real Java Parquet DECIMAL cases pass across compact/wide decimals, both equal-timestamp policies, aggregation/partial-update, multiple commits, full compaction and reopening. The Java-written Unicode partial-update table is rejected explicitly before an unsafe Native read. Native0.5.0 MERGE and sequence-group probes still reproduce the two functional issues, and the exact-base MERGE control agrees across source forms. Project-configured changed-file flake8 still fails at native_merge_map_keytime_fallback_test.py:426, matching current CI.

One additional availability regression is reproduced below, with an exact-base control. No production sources were modified.

PyRSA and others added 10 commits November 19, 2026 14:29
…lback

Inline the STRING timestamp probe so NativeTableRead stays within the
execution.native boundary and passes the backend isolation check.

Co-authored-by: Cursor <cursoragent@cursor.com>
Route all merge_map_with_keytime reads through Python before Native
opens (STRING UTF-16 vs Rust UTF-8; typed keytime never had a correct
Native path). Drop the Python timestamp whitelist so historical
BINARY/VARBINARY/BOOLEAN and other comparable types remain readable.
Add field-level Native read gating for STRING keytime aggregators.

Keep Native reads available when projections and predicates do not access keytime fields.

Materialize STRING keytime MERGE sources through the Python reader while preserving source eligibility and query authorization.

Reject unsupported Partial Update keytime MERGE sources before backend dispatch.

Keep public and Native self-merge handling consistent.

Add regression tests for keytime fallback, VARIANT projections, MERGE source materialization, and query authorization.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PyRSA
PyRSA force-pushed the feature/merge-map-with-keytime-more-types branch from f0e5647 to 45ebabf Compare November 19, 2026 06:57

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new DECIMAL keytime support has end-to-end value. A two-commit PyPaimon Parquet table with DECIMAL(23,6) retained the correct winner in Java reads before and after full compaction. I ran 289 Java, 241 Python, and 69 Native-mode cases with normal checks. The prior Native table-source MERGE and Variant projection tests passed. Three public API compatibility cases still reproduce.

The timestamp field supports `CHAR`, `VARCHAR`, `TINYINT`, `SMALLINT`, `INTEGER`, `BIGINT`, `DATE`, `TIME`,
`DECIMAL`, `TIMESTAMP` and `TIMESTAMP_LTZ`.
Spark's `TIMESTAMP_NTZ` maps to Paimon's `TIMESTAMP` and is also supported.
`CHAR` / `VARCHAR` timestamps use UTF-16 code unit lexicographical ordering: Java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Keep the same STRING winner through PyPaimon SQL

I used U+E000/first and U+10000/second at the same PK and map key. On the merge base public table reads and SQL both returned second. The revised Python table route now returns first, while the public Rust-backed SQLContext still returns second from the same two files. A SQL INSERT of both versions in one Arrow batch persists second, so a later corrected Python read cannot recover first. SQLContext and the CLI bypass the Python gates. Implement matching Native ordering or reject affected SQL operations before they read or coalesce the rows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this issue out.

This inconsistency stems from the comparison semantics for STRING type keys within the Rust-based SQL execution path; it is independent of the Python-based table read/write implementation addressed in this PR. A comprehensive fix would require modifying the underlying native execution path, which is outside the scope of this PR.

I would prefer to address this in a separate PR rather than further expanding the scope of the current one.

@JingsongLi

Copy link
Copy Markdown
Contributor

@PyRSA Why was this added? Does it stem from an actual requirement in the online production environment?

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.

3 participants