Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2041

When ReduceExpressionRule simplifies a nullable expression, allow the result to change type to NOT NULL

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.15.0
    • Component/s: None
    • Labels:
      None

      Description

      In some cases, the user needs to select whether or not to add casts that match nullability.
      One of the motivations behind this is to avoid unnecessary casts like the following example.
      original filter

      OR(AND(>=($0, CAST(_UTF-16LE'2010-01-01 00:00:00 UTC'):TIMESTAMP_WITH_LOCAL_TIME_ZONE(15)), <=($0, CAST(_UTF-16LE'2012-03-01 00:00:00 UTC'):TIMESTAMP_WITH_LOCAL_TIME_ZONE(15))))
      

      the optimized expression with matching nullability

      OR(AND(CAST(>=($0, 2010-01-01 00:00:00)):BOOLEAN, CAST(<=($0, 2012-03-01 00:00:00)):BOOLEAN))
      

      As you can see this extra cast gets into the way of following plan optimization steps.
      The desired expression can be obtained by turning off the nullability matching.

      OR(AND(>=($0, 2010-01-01 00:00:00), <=($0, 2012-03-01 00:00:00)))
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                bslim slim bouguerra
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: