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

CBO : When filter is applied on dimension table PK/FK code path is not in effect.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.14.0
    • 0.14.0
    • CBO
    • None

    Description

      When a filter is applied on PK side joins don't qualify as PK/FK join.

      In getUniqueKeys when a filter is applied on the table the child is no longer a table scan.

        public Set<BitSet> getUniqueKeys(ProjectRelBase rel, boolean ignoreNulls) {
      
          RelNode child = rel.getChild();
      
          if (!(child instanceof HiveTableScanRel)) {
            Function<RelNode, Metadata> fn = RelMdUniqueKeys.SOURCE.apply(
                rel.getClass(), BuiltInMetadata.UniqueKeys.class);
            return ((BuiltInMetadata.UniqueKeys) fn.apply(rel))
                .getUniqueKeys(ignoreNulls);
          } 
      

      Repro

      with ss as 
      (select 
          ss_customer_sk, ss_item_sk, ss_ticket_number
      from
          store_sales,
          store
      where
          s_store_sk = ss_store_sk
              and s_market_id = 4), 
      sr as
      (select sr_customer_sk,sr_item_sk ,sr_ticket_number from store_returns, store where s_store_sk = sr_store_sk and s_market_id=4) 
      select 
          count(*)
      from
          ss,
          sr
      where
          ss_customer_sk = sr_customer_sk
              and ss_item_sk = sr_item_sk
              and ss_ticket_number = sr_ticket_number;
      

      Attachments

        1. HIVE-8280.1.patch
          2 kB
          Harish Butani
        2. HIVE-8280.2.patch
          2 kB
          Harish Butani
        3. HIVE-8280.3.patch
          6 kB
          Harish Butani

        Issue Links

          Activity

            People

              rhbutani Harish Butani
              mmokhtar Mostafa Mokhtar
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: