Wenhai created ASTERIXDB-1718: --------------------------------- Summary: Condition expression propagation in general cases. Key: ASTERIXDB-1718 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1718 Project: Apache AsterixDB Issue Type: Bug Environment: Common systems. Reporter: Wenhai
Given a query with an inlined condition such as tpch-q17: {noformat} use dataverse tpch; declare function tmp(){ for $l in dataset('LineItem') group by $l_partkey := $l.l_partkey with $l return { "t_partkey": $l_partkey, "t_avg_quantity": 0.2 * avg(for $i in $l return $i.l_quantity) } } sum( for $l in dataset('LineItem') for $p in dataset('Part') where $p.p_partkey = $l.l_partkey and $p.p_container = 'MED BOX' for $t in tmp() where $l.l_partkey = $t.t_partkey and $l.l_quantity < $t.t_avg_quantity return $l.l_extendedprice )/7.0 {noformat} We should provide a general strategy to push the required primarykey join down to the downstreaming inlined operators. Just run the query as following: {noformat} use dataverse tpch; declare function tmp(){ for $l in dataset('LineItem') for $p in dataset('Part') where $p.p_partkey = $l.l_partkey and $p.p_container = 'MED BOX' group by $l_partkey := $l.l_partkey with $l return { "t_partkey": $l_partkey, "t_avg_quantity": 0.2 * avg(for $i in $l return $i.l_quantity) } } sum( for $l in dataset('LineItem') for $p in dataset('Part') where $p.p_partkey = $l.l_partkey and $p.p_container = 'MED BOX' for $t in tmp() where $l.l_partkey = $t.t_partkey and $l.l_quantity < $t.t_avg_quantity return $l.l_extendedprice )/7.0 {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)