Zoltán Borók-Nagy created IMPALA-15843:
------------------------------------------
Summary: No min/max runtime filter when a scalar subquery is
written as a CROSS JOIN
Key: IMPALA-15843
URL: https://issues.apache.org/jira/browse/IMPALA-15843
Project: IMPALA
Issue Type: Improvement
Components: Frontend
Reporter: Zoltán Borók-Nagy
IMPALA-3430 builds a min/max filter for a range predicate against an
uncorrelated scalar subquery. RuntimeFilterGenerator only does it when the
nested loop join's build child is an AggregationNode flagged
isNonCorrelatedScalarSubquery, which StmtRewriter sets only when it rewrites a
subquery. The same query written as a CROSS JOIN with a non-grouping
aggregation in an inline view or WITH clause, which also returns at most one
row, gets no filter and scans the whole table.
Example on master, 6 executors, an Iceberg table with 14,600 partitions; both
queries return 5,144,433:
{noformat}
-- 1.6 s; RF000[min_max] -> cpd_date
SELECT COUNT(*) FROM t WHERE cpd_date >=
(SELECT CAST(to_date(date_sub(CAST(MAX(cpd_date) AS TIMESTAMP), 7)) AS
STRING) FROM t);
-- 6.7 s; no runtime filter
WITH mx AS (SELECT MAX(cpd_date) AS max_d FROM t)
SELECT COUNT(*) FROM t CROSS JOIN mx
WHERE cpd_date >= CAST(to_date(date_sub(CAST(mx.max_d AS TIMESTAMP), 7)) AS
STRING);
{noformat}
Could the filter be generated whenever the build side of the nested loop join
returns at most one row, for example a non-grouping aggregation?
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)