Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2449 RexSimplify overhaul
  3. CALCITE-2450

RexSimplify: reorder predicates to a canonical form as a part of RexSimplify

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.17.0
    • 1.22.0
    • core

    Description

      Certain optimizations are easier to perform when input expressions are in a canonical form.
      For instance: more duplicates can be found in AND/OR lists, case branches, etc.

      Note: this reordering is supposed to happen in RexSimplify only. In other words, RexBuilder would still produce "non-canonical" expressions.

      It is expected that RexSimplify might alter the expression, so if it converts 5=x to x=5 it should be just fine.

      The suggested rules are to be discussed, yet the following might be fine:
      1) For AND, OR, IN: put "simpler" nodes first. The weight of a node could be either .toString().length() or a number of child nodes or something like that.
      The motivation is to simplify logic that handles "duplicate" entries. It won't have to consider "both alternatives" all over the place.
      2) For comparison with literals put literal as the second argument
      3) For binary comparison, put node with less weight to the left

      Attachments

        Issue Links

          Activity

            People

              vladimirsitnikov Vladimir Sitnikov
              vladimirsitnikov Vladimir Sitnikov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 5h 50m
                  5h 50m