Skip to content

[core] Trim fixed-width ORC CHAR padding before filtering - #1516

Open
miomiocat wants to merge 1 commit into
apache:mainfrom
miomiocat:codex/orc-char-padding
Open

miomiocat wants to merge 1 commit into
apache:mainfrom
miomiocat:codex/orc-char-padding

Conversation

@miomiocat

Copy link
Copy Markdown

Purpose

Closes #1515.

Make a padded ORC CHAR value compare the same way as the logical Paimon value, including when a predicate is evaluated during the read.

Brief change log

  • Remove trailing ASCII spaces according to the logical Paimon type, recursing into array, map and row children.
  • Skip raw string statistics comparisons for CHAR literals. Evaluate residual predicates on the normalized values.

Tests

Added a sliced-array case covering nulls, leading spaces, all-padding values, tabs, nonbreaking spaces and the same inputs read as VARCHAR.

Local verification passed with cargo build --locked -p paimon --lib and cargo fmt --all -- --check. Test execution is left to upstream CI.

API and Format

The change affects decoded ORC CHAR values and predicates on them. It uses the existing read API and file format.

Documentation

The behavior follows the fixed-width CHAR semantics of the Java reader.

Remove trailing ASCII spaces from CHAR values, including nested fields.
Keep VARCHAR values intact and bypass statistics that compare padded data.
Normalize decoded values before evaluating residual predicates.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 146/146
AI-Contributed/UT: 0/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.

Decoding padded ORC CHAR values has a concrete interoperability benefit. The 29 ORC tests passed, and a real ORC CHAR(4) fixture returned the correct equality match, nested element and untouched VARCHAR. The table-scan regression below still drops that match with Java-style file statistics.

(Datum::Double(value), DataType::Double(_)) => Some(PredicateValue::Float64(Some(*value))),
(Datum::String(value), DataType::Char(_) | DataType::VarChar(_)) => {
// CHAR values are normalized before residual evaluation; raw padded ORC
// statistics must not exclude a matching unpadded value.

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] Prevent manifest statistics from dropping padded CHAR matches before the ORC reader opens the file. Java's OrcSimpleStatsExtractor copies the raw string bounds into file metadata. I confirmed that a physical CHAR(4) file stores an AB value as AB in its stats. I wrote a table with the same padded values, committed its file with Java-style bounds (AB to CD ), and planned code = 'AB'. The plan contained zero splits, although the direct ORC read correctly returned AB. Make table-level file pruning fail open for these CHAR comparisons or use safe normalized bounds, and exercise the full TableScan path in a regression test.

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.

ORC CHAR padding can change predicate results

2 participants