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

Extract common expressions for disjunctions in Join

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.37.0
    • None
    • core

    Description

      For SQL:

      select *
      from tbl_a
        join tbl_b on tbl_a.id = tbl_b.id
      where (tbl_a.x > 100 and tbl_b.y < 10)
         or (tbl_a.x > 100 and tbl_b.z > 20)

      we can rewrite it to

      select *
      from tbl_a
        join tbl_b on tbl_a.id = tbl_b.id
      where tbl_a.x > 100
        and (tbl_b.y < 10 or tbl_b.z > 20)

      And in this way tbl_a.x > 100 can be pushed down and it is likely that this will help reduce the amount of data involved in the join.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              frostruan ruanhui
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: