[ 
https://issues.apache.org/jira/browse/HIVE-20432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603938#comment-16603938
 ] 

Ashutosh Chauhan commented on HIVE-20432:
-----------------------------------------

1. Instead of  if (leftValue instanceof Integer) {..} else if (leftValue 
instanceof Long) {...} else {} you may simply do 
long leftVal = ((Number) leftValue).longValue() concise and simpler to read.
2. In isIntegerType() you also need to add  || primitiveCategory == 
PrimitiveCategory.BYTE in if () for tinyint.

+1 pending these changes.

> Rewrite BETWEEN to IN for integer types for stats estimation
> ------------------------------------------------------------
>
>                 Key: HIVE-20432
>                 URL: https://issues.apache.org/jira/browse/HIVE-20432
>             Project: Hive
>          Issue Type: Improvement
>    Affects Versions: 4.0.0
>            Reporter: Vineet Garg
>            Assignee: Vineet Garg
>            Priority: Major
>         Attachments: HIVE-20432.1.patch, HIVE-20432.2.patch, 
> HIVE-20432.3.patch
>
>
> IN clause provides better statistics estimation since predicates are equality 
> based and it keeps into account selectivity of all values. BETWEEN is 
> rewritten into {{>= AND <=}} i.e. non-equality predicates which cause worse 
> estimation. For integer types BETWEEN could be rewritten into IN e.g. BETWEEN 
> 4 and 7 is equivalent to IN (4,5,6,7).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to