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
Attachments
Issue Links
- is a clone of
-
HIVE-8263 CBO : TPC-DS Q64 is item is joined last with store_sales while it should be first as it is the most selective
- Closed