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

Allow SqlOperator of SqlKind#OTHER_FUNCTION to define a Strong.Policy

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.24.0
    • core

    Description

      FilterJoinRule performs some optimizations based on RelOptUtil#simplifyJoin. Specifically, this part of the code:

      if (joinType.generatesNullsOnRight()
        && Strong.isNotTrue(filter, rightBitmap)) {
          joinType = joinType.cancelNullsOnRight();
      }
      

      allows e.g. a LEFT join with a condition on its RHS to be transformed into an INNER join, with the condition pushed on its right input.

      In order to achieve this, the utility class Strong defines a certain Policy map, depending on the SqlKind of a RexNode (i.e. depending on the filter condition). In case of operators such as EQUALS, NOT_EQUALS, LESS_THAN, etc, it defines Policy.ANY (i.e. expression is null if and only if at least one of its arguments is null). In case of a left join with conditions with this policy on the right-hand-side, the join gets simplified by this module because of the nullability of the right columns. However, in the case of SqlUserDefinedFunction the policy is the default Policy.AS_IS, which prevents the simplification from happening.

      It is proposed to enrich SqlUserDefinedFunction with an optional Strong.Policy, and adapt Strong code so that these functions can also benefit from this simplification.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rubenql Ruben Q L
            rubenql Ruben Q L
            Votes:
            0 Vote for this issue
            Watchers:
            5 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 - 1.5h
                1.5h

                Slack

                  Issue deployment