Skip to content

[spark] Guard lake split partition pruning against malformed splits - #3836

Open
Yohahaha wants to merge 2 commits into
apache:mainfrom
Yohahaha:spark-lake-split-partition-pruning-guard
Open

[spark] Guard lake split partition pruning against malformed splits#3836
Yohahaha wants to merge 2 commits into
apache:mainfrom
Yohahaha:spark-lake-split-partition-pruning-guard

Conversation

@Yohahaha

@Yohahaha Yohahaha commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Contribution Checklist

  • The pull request title follows the format "[component] Title of the pull request".

  • The change addresses a single issue/bug.

  • Automated tests were run and the relevant test suite passed.

  • This PR corresponds to a GitHub issue (issue number to be added before final review).

  • Generative AI disclosure:

    • No generative AI tools used
    • Yes: AI coding assistant

Purpose

Linked issue: N/A

Harden partition pruning for Spark lake splits so that a split whose reported partition values do not match the table's partition key arity is rejected instead of being admitted silently. This prevents rows from non-matching partitions from leaking into the query result, and avoids an unreadable IndexOutOfBoundsException when the value tuple is too long.

Also consolidate the predicate utility tests to remove duplicated Spark DSv2 predicate helpers.

Brief change log

  • SparkPartitionPredicate.matchesPartition now validates that the partition value tuple size equals the number of partition keys, and throws a clear IllegalArgumentException on mismatch.
  • Merged SparkPredicateConverterTest and SparkPartitionPredicateTest into a single SparkPredicateUtilsTest suite.

Tests

  • fluss-spark/fluss-spark-ut/src/test/scala/org/apache/fluss/spark/utils/SparkPredicateUtilsTest (44 tests, all passed).
  • Verified the arity-guard tests fail on the pre-fix behavior.

API and Format

No public API or storage format changes.

Documentation

No new feature or user-facing documentation change.

…ion keys

SparkPartitionPredicate.matchesPartition previously admitted any split with
empty or partial partition values when a partition predicate was pushed,
because the scan builder removes the partition predicate from the post-scan
filters handed back to Spark. Such splits were never re-filtered, so rows
from non-matching partitions could leak into the query result. A longer
value tuple even crashed with an unreadable IndexOutOfBoundsException.

Now validate that the split reports exactly one value per partition key and
fail fast with a descriptive IllegalArgumentException otherwise, since the
arity mismatch means the lake plugin broke the LakeSplit#partition contract.

Add SparkPartitionPredicateTest covering extraction and matching, including
guard tests that fail on the pre-fix behavior.
The new SparkPartitionPredicate tests and the existing
SparkPredicateConverter tests are both unit tests for predicate utilities
in the same package and share the same Spark DSv2 predicate helpers.
Consolidate them into a single SparkPredicateUtilsTest suite so that
ref/lit/pred helpers are not duplicated and the test surface is easier to
maintain.
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