Skip to content

NotStartsWith residual evaluation always returns false #3496

Closed

Description

@kevinjqliu

ResidualVisitor.visit_not_starts_with appears to always return AlwaysFalse() for partitioned residuals because it applies Python not to the AlwaysTrue() / AlwaysFalse() object returned by visit_starts_with.

Example with an identity partition:

partition value: x_part = "bb"
filter: NotStartsWith("x", "a")
actual residual: AlwaysFalse()
expected residual: AlwaysTrue()

This can attach an incorrect residual to planned scan tasks.

Relevant code: pyiceberg/expressions/visitors.py ResidualVisitor.visit_not_starts_with.

Activity

  1. kevinjqliu commented on Jun 13, 2026

    @kevinjqliu
    ContributorAuthor

    Verified against the current worktree.

    StartsWith("x", "a") on identity partition "aa" -> AlwaysTrue()
    NotStartsWith("x", "a") on identity partition "aa" -> AlwaysFalse()
    NotStartsWith("x", "a") on identity partition "bb" -> AlwaysFalse()  # expected AlwaysTrue()
    

    Root cause is ResidualVisitor.visit_not_starts_with: it applies Python not to an AlwaysTrue() / AlwaysFalse() expression object, and both objects are truthy.

  2. added a commit that references this issue on Jun 21, 2026
    b9185ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions