You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Quanlong Huang (Jira)" <ji...@apache.org> on 2020/11/12 10:54:00 UTC
[jira] [Created] (IMPALA-10322) Constant folding in the SelectList
using predicates
Quanlong Huang created IMPALA-10322:
---------------------------------------
Summary: Constant folding in the SelectList using predicates
Key: IMPALA-10322
URL: https://issues.apache.org/jira/browse/IMPALA-10322
Project: IMPALA
Issue Type: Improvement
Components: Frontend
Reporter: Quanlong Huang
It seems like we are missing some opportunities for constant folding in the select list using the predicates. In the following query:
{code:sql}
select count(if(year=2010, 1, null)) from functional.alltypes
where year=2010;
{code}
The plan is
{code:java}
| PLAN-ROOT SINK |
| | |
| 03:AGGREGATE [FINALIZE] |
| | output: count:merge(if(`year` = 2010, 1, NULL)) |
| | row-size=8B cardinality=1 |
| | |
| 02:EXCHANGE [UNPARTITIONED] |
| | |
| 01:AGGREGATE |
| | output: count(if(`year` = 2010, 1, NULL)) |
| | row-size=8B cardinality=1 |
| | |
| 00:SCAN HDFS [functional.alltypes] |
| partition predicates: `year` = 2010 |
| HDFS partitions=12/24 files=12 size=239.77KB |
| row-size=4B cardinality=3.65K
{code}
"if(year=2010, 1, null)" can be rewritten to "1" since the year column will always be 2010. So it can be rewritten to
{code:sql}
select count(1) from functional.alltypes
where year=2010;
{code}
This save the evalution of the IF function which is usually slow.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org