Skip to content

[Enhancement] Support partial pushdown for AND compound predicates in Iceberg connector (backport #70293) - #73085

Merged
wanpengfei-git merged 1 commit into
branch-4.1from
mergify/bp/branch-4.1/pr-70293
Jun 8, 2026
Merged

[Enhancement] Support partial pushdown for AND compound predicates in Iceberg connector (backport #70293)#73085
wanpengfei-git merged 1 commit into
branch-4.1from
mergify/bp/branch-4.1/pr-70293

Conversation

@mergify

@mergify mergify Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Why I'm doing:

When converting StarRocks SQL predicates to Iceberg expressions in ScalarOperatorToIcebergExpr.visitCompoundPredicate(), if an AND(left, right) compound predicate has only one convertible side, the entire predicate is discarded. This is unnecessarily conservative -- for AND semantics, pushing down the convertible side alone is still a valid filter (it may include extra rows but never excludes valid ones). This missed optimization prevents partition pruning and data skipping in cases where at least one side of an AND predicate is pushable.

What I'm doing:

  1. Added insideNot tracking to IcebergContext: Added a boolean insideNot field with a withInsideNot() factory method. When visiting the child of a NOT expression, the context is marked as inside-NOT to prevent unsafe partial pushdown.

  2. Implemented AND partial pushdown in visitCompoundPredicate(): After the existing check for both sides being non-null, added logic that returns the single convertible side when:

    • The operator is AND (not OR)
    • We are NOT inside a NOT expression (De Morgan safety: NOT(AND(a,b)) = OR(NOT(a), NOT(b)))
  3. Added comprehensive tests in IcebergExprVisitorTest:

    • AND(convertible, unconvertible) returns the convertible side
    • AND(unconvertible, convertible) returns the convertible side
    • OR(convertible, unconvertible) still returns null (no partial pushdown)
    • NOT(AND(convertible, unconvertible)) returns null (De Morgan safety)
    • AND(convertible1, convertible2) still returns and(left, right) (regression)
    • Nested AND(AND(convertible, unconvertible), convertible2) returns and(convertible, convertible2)

Fixes #70292

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5
    • 3.4

This is an automatic backport of pull request #70293 done by [Mergify](https://mergify.com).

… Iceberg connector (#70293)

Signed-off-by: Jiwon Park <jpark92@outlook.kr>
(cherry picked from commit 391d4e3)
@wanpengfei-git
wanpengfei-git merged commit d1a5a61 into branch-4.1 Jun 8, 2026
36 checks passed
@wanpengfei-git
wanpengfei-git deleted the mergify/bp/branch-4.1/pr-70293 branch June 8, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants