[
https://issues.apache.org/jira/browse/HIVE-29424?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stamatis Zampetakis resolved HIVE-29424.
----------------------------------------
Fix Version/s: 4.3.0
Resolution: Fixed
Fixed in
[https://github.com/apache/hive/commit/301bfb57f67e10e92fb84569cbf62066d056886a]
Many thanks for the PR [~thomas.rebele] ! I really appreciate your patience
over the multiple rounds of reviews. I admit that I was very picky on some
parts and this led to delays while we could have merged this sooner.
> CBO plans should use histogram statistics for range predicates with a CAST
> --------------------------------------------------------------------------
>
> Key: HIVE-29424
> URL: https://issues.apache.org/jira/browse/HIVE-29424
> Project: Hive
> Issue Type: Improvement
> Reporter: Thomas Rebele
> Assignee: Thomas Rebele
> Priority: Major
> Labels: pull-request-available
> Fix For: 4.3.0
>
>
> Similar to HIVE-29364: the CBO planner should use the histogram statistics to
> estimate the selectivity of predicates such as
> * {{cast(b as BIGINT) < 6}}
> * {{cast(g as timestamp) >= "2020-11-7 00:00:00"}}
> * {{cast(g as timestamp) BETWEEN "2020-11-01 00:00:00" AND "2020-11-06
> 00:00:00"}}
> The hint of HIVE-29364 should be taken into account: if the CAST throws away
> information, the histogram statistics should not be used. E.g., {{{}CAST(128
> as TINYINT) = -128{}}}, so a {{CAST(intField as TINYINT) > 42}} should not be
> treated the same as {{{}intField > 42{}}}, if the intField is outside of the
> range of TINYINT. (_Update:_ this only considers casts from an integer field
> to an integer type)
> This change would allow Hive to use the histogram statistics for many TPC-DS
> queries, e.g., query 82 contains a {{{}d_date between cast('2002-05-30' as
> date) and (cast('2002-05-30' as date) + 60 days){}}}, which will be
> implicitly converted to a RexNode {{{}BETWEEN(false, CAST($2):TIMESTAMP(9),
> 2002-05-30 00:00:00:TIMESTAMP(9), 2002-07-29 00:00:00:TIMESTAMP(9)){}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)