Skip to content

[Kernel] Make data skipping column lookups case-insensitive - #7579

Open
nanjeshramesh wants to merge 1 commit into
delta-io:masterfrom
nanjeshramesh:fix-6247-case-insensitive-data-skipping
Open

[Kernel] Make data skipping column lookups case-insensitive#7579
nanjeshramesh wants to merge 1 commit into
delta-io:masterfrom
nanjeshramesh:fix-6247-case-insensitive-data-skipping

Conversation

@nanjeshramesh

Copy link
Copy Markdown

Description

Fixes the bug described in #6247: Java Kernel's StatsSchemaHelper
matched columns for data skipping using Column's own equals/
hashCode, which are case-sensitive by design. A predicate like
col > 5 would silently fail to match a schema column named Col,
so data skipping just wouldn't apply, no error, just a missed
optimization. This is inconsistent with the protocol, which requires
column names be unique regardless of casing, and with Delta Spark,
which already handles this correctly via equalsIgnoreCase.

How

Rather than changing Column's equality (it's intentionally
case-sensitive and used broadly elsewhere in the kernel for exact-name
resolution), StatsSchemaHelper's two internal lookup maps are now
keyed by a case-folded form of the column's path instead of by
Column directly. This scopes the case-insensitive matching to just
the stats/skipping lookups. It mirrors the fix already merged on the
Rust kernel side (delta-kernel-rs#2055), which takes the same
case-fold-the-lookup-key approach rather than touching column-name
equality globally.

This PR does NOT:

  • Change Column's equals/hashCode or its case-sensitivity
    elsewhere in the kernel
  • Change the on-disk format or any public API signature

How was this patch tested?

Added test cases to StatsSchemaHelperSuite:

  • A mixed-case schema column (Value) matched by a lowercase query
    (value), and the same in reverse
  • A nested column matched case-insensitively at every path segment
  • Confirmation that a genuinely nonexistent column is still correctly
    rejected (no false positives from the case-folding)

Verified each new test fails against the pre-fix code with the exact
mismatch the issue describes, and passes with the fix. Ran the full
skipping package test suite (15 tests, StatsSchemaHelperSuite +
DataSkippingUtilsSuite), all passing.

Does this PR introduce any user-facing changes?

No public API or on-disk format changes. Behavior change only: data
skipping now applies correctly for predicates that reference a column
using different casing than the schema, matching Delta Spark's
existing behavior.

Delta column names are case-insensitive per the protocol spec: "All
column names must be unique regardless of casing." Delta Spark honors
this in the data skipping path via equalsIgnoreCase, but the Java
Kernel's StatsSchemaHelper built its logical-to-physical and
logical-to-data-type maps keyed directly by Column, whose equals and
hashCode are case-sensitive by design. A predicate like col > 5 would
silently fail to match a schema column named Col, and data skipping
would just not apply, no error, just a missed optimization.

Column itself stays case-sensitive on purpose, it's used broadly for
exact-name resolution elsewhere in the kernel, and changing its
equals/hashCode would be a much bigger, riskier change than this bug
calls for. Instead, StatsSchemaHelper's two internal maps are now
keyed by a case-folded form of the column's path (each path segment
lowercased) rather than by Column directly, matching the approach
already taken on the Rust kernel side for the equivalent bug
(delta-kernel-rs#2055), which case-folds the lookup key in the schema
traversal rather than changing column-name equality everywhere.

Delta's own protocol guarantee, that no schema can contain two leaf
columns whose paths fold to the same key, means this can't introduce
a collision that wasn't already prevented at the table level.

Added tests to StatsSchemaHelperSuite covering: a mixed-case schema
column matched by a lowercase query and vice versa, a nested column
matched case-insensitively at every path segment, and confirmation
that a genuinely nonexistent column is still correctly rejected.

Closes delta-io#6247.

Signed-off-by: Nanjesh Ramesh <nanjeshramesh7@gmail.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.

1 participant