Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-20333

CBO: Join removal based on PK-FK declared constraints

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      A query of the following shape can have its customer join removed entirely on the basis of the key containment between customer & store_sales.

      select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales from store_sales ,customer where ss_customer_sk = c_customer_sk group by c_customer_sk;
      

      This query after join removal can be encoded in as

      select ss_customer_sk as c_customer_sk,sum(ss_quantity*ss_sales_price) ssales from store_sales where ss_customer_sk is not null group by ss_customer_sk;
      

      The rewrite is not applied today and the current PK-FK relationship does not allow for a nullable relationship (i.e a declared Foreign Key can't be NULL).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gopalv Gopal Vijayaraghavan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: