Skip to content

Add additional simplification rules #1406

Closed

Description

@alamb

As pointed out by @xudong963 on #1376, there are several other rewrite rules we could add following the pattern in simplify:

A AND !(A) --> false (if A is not nullable)

Note that if A is null (or some expresson that could be null), then A AND !(A) is NULL

Similarly,

A * 0 --> 0 (if A is not nullable)

The "is nullable" bit is somewhat tricky -- and to be honest I am not sure our current code handles all such cases correctly either.

Activity

  1. Jefffrey commented on Nov 14, 2022

    @Jefffrey
    Contributor

    A * 0 --> 0 (if A is not nullable)

    Is already implemented:

    https://github.com/apache/arrow-datafusion/blob/b58ec81ab06af7a267ee69b834715727dbef963d/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L580-L591

    A AND !(A) --> false (if A is not nullable)

    Implemented by #4200

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions