[ 
https://issues.apache.org/jira/browse/HIVE-2249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joseph Barillari updated HIVE-2249:
-----------------------------------

    Attachment: HIVE-2249.1.patch.txt

As explained in the comments in TypeCheckProcFactory, this patch implements 
this fix. It also optimizes impossible comparisons (int column and double 
constant) to FALSE. 

It also includes a new unit test, type_matching.q. Note that this test does 
(and should) produce slightly different output between the trunk version and 
the patched version, since it runs EXPLAIN SELECT on several queries that this 
patch will modify, so the string outputs (e.g., "22" vs "22.0" are different.)

> When creating constant expression for numbers, try to infer type from another 
> comparison operand, instead of trying to use integer first, and then long and 
> double
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-2249
>                 URL: https://issues.apache.org/jira/browse/HIVE-2249
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Siying Dong
>         Attachments: HIVE-2249.1.patch.txt
>
>
> The current code to build constant expression for numbers, here is the code:
>      try {
>         v = Double.valueOf(expr.getText());
>         v = Long.valueOf(expr.getText());
>         v = Integer.valueOf(expr.getText());
>       } catch (NumberFormatException e) {
>         // do nothing here, we will throw an exception in the following block
>       }
>       if (v == null) {
>         throw new SemanticException(ErrorMsg.INVALID_NUMERICAL_CONSTANT
>             .getMsg(expr));
>       }
>       return new ExprNodeConstantDesc(v);
> The for the case that "WHERE <BIG_INT_COLUMN> = 0", or "WHERE <DOUBLE_COLUMN> 
> = 0", we always have to do a type conversion when comparing, which is 
> unnecessary if it is slightly smarter to choose type when creating the 
> constant expression. We can simply walk one level up the tree, find another 
> comparison party and use the same type with that one if it is possible. For 
> user's wrong query like '<INT_COLUMN>=1.1', we can even do more.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to