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

RexSimplify: avoid multiple similar optimization passes over the same nodes

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      simplifyAndTerms(List<RexNode> terms) has two loops and it calls simplify on each expression twice.

      simplifyAnd(RexCall e) calls simplifyList (that walks all the tree down), then simplifyAnd2ForUnknownAsFalse calls simplify_ again.

      It looks like just one pass should be sufficient for most of the cases, and the logic should probably be adjusted as follows:

      simplify(RexNode node){
        // e.g. simplify the node with assumption that all the arguments were simplified, etc, avoid complicated checks
        node = simplifyTrivialCases(node); 
      
        // this walks over the tree, simplifies operands first then simplifies the call itself
        node = simplifyArgumentsThenSimplifyNode(node); 
        return node;
      }

      Method naming should clearly indicate that the method is heavy, so it would not accidentally be used.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: