Skip to content

Apply early SqlExpression optimizations (e.g. x AND true -> x) in VisitChildren #34556

@roji

Description

@roji

We have been starting to apply certain optimizations early, at creation in SqlExpressionFactory; for example, if someone calls SqlExpressionFactory.MakeBinary with x AND true, x is returned.

We should do the same optimizations in e.g. SqlBinaryExpression.VisitChildren(), and possibly even in SqlBinaryExpression.Update(). This will ensure that arbitrary visitors that happen to simplify an operand of a binary expression would transparently get the whole binary expression optimized away.

Ideally, we'd factor things in a way that the same simplification code is used from both SqlExpressionFactory and from SqlBinaryExpression itself (probably have the code on SqlBinaryExpression and call it from SqlExpressionFactory).

(note that this applies to other expression types, not just SqlBinaryExpression)

/cc @ranma42

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions