Skip to content

[python] Fix external partition predicate index mismatch in partition pruning#8507

Open
XiaoHongbo-Hope wants to merge 3 commits into
apache:masterfrom
XiaoHongbo-Hope:partition_filter_fix
Open

[python] Fix external partition predicate index mismatch in partition pruning#8507
XiaoHongbo-Hope wants to merge 3 commits into
apache:masterfrom
XiaoHongbo-Hope:partition_filter_fix

Conversation

@XiaoHongbo-Hope

@XiaoHongbo-Hope XiaoHongbo-Hope commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Purpose

An external partition filter (with_partition_filter) built from the full table schema carries full-row leaf indices, but partition pruning tests it against a partition-only row. When a partition key isn't a schema prefix, this throws
IndexError, or silently prunes the wrong partitions (drops matching / keeps non-matching).

Tests

partition_predicate_test.py

… pruning

External partition predicates are built from the full table schema, so their
leaf indices are full-schema positions. Partition pruning evaluates them against
a partition-only row (partition_keys_fields layout), causing IndexError or silent
wrong pruning. Rebind leaf indices by field name to the partition layout.
Rebinding an external partition predicate raised when it referenced a
non-partition column. with_partition_filter is a public API with no validation,
so a mixed filter (partition AND non-partition leaves) would throw instead of
pruning on the partition part. Drop non-partition leaves before rebinding,
matching the derived path and Java's pickTransformFieldMapping.
@XiaoHongbo-Hope XiaoHongbo-Hope marked this pull request as ready for review July 8, 2026 13:27
…ilter

Locks the silent wrong-pruning mode: when partition keys are reordered vs
the table schema, a full-schema leaf index is in-range but points at the wrong
partition field, dropping matching rows. Verified to fail without the rebind.
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