Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0
    • 4.0.0-alpha-1
    • Logical Optimizer
    • None

    Description

      If the PK/UK table is not filtered, we can safely remove the join.

      A simple example:

      SELECT c_current_cdemo_sk
      FROM customer, customer_address
      ON c_current_addr_sk = ca_address_sk;
      

      As a Calcite rule, we could implement this rewriting by 1) matching a Project on top of a Join operator, 2) checking that only columns from the FK are used in the Project, 3) checking that the join condition matches the FK - PK/UK relationship, 4) pulling all the predicates from the PK/UK side and checking that the input is not filtered, and 5) removing the join, possibly adding a IS NOT NULL condition on the join column from the FK side.

      If the PK/UK table is filtered, we should still transform the Join into a SemiJoin operator.

      Attachments

        1. HIVE-17040.01.patch
          242 kB
          jcamachorodriguez
        2. HIVE-17040.02.patch
          260 kB
          jcamachorodriguez
        3. HIVE-17040.04.patch
          271 kB
          jcamachorodriguez
        4. HIVE-17040.05.patch
          275 kB
          jcamachorodriguez
        5. HIVE-17040.06.patch
          276 kB
          jcamachorodriguez
        6. HIVE-17040.07.patch
          276 kB
          jcamachorodriguez
        7. HIVE-17040.patch
          59 kB
          jcamachorodriguez

        Issue Links

          Activity

            People

              jcamacho Jesús Camacho Rodríguez
              jcamacho Jesús Camacho Rodríguez
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: