You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by Sean Hsuan-Yi Chu <hs...@usc.edu> on 2015/04/01 01:05:22 UTC

Re: Review Request 32591: DRILL-2590: In implicit casting rule, make boolean to be implicitly castable from boolean only


> On March 31, 2015, 1:30 a.m., Aman Sinha wrote:
> > exec/java-exec/src/main/java/org/apache/drill/exec/resolver/TypeCastRules.java, line 550
> > <https://reviews.apache.org/r/32591/diff/1/?file=908344#file908344line550>
> >
> >     I think disabling this will cause certain valid explicit type casting to fail - for example if an integer column has values 1 and 0, then cast(col as boolean) should produce true and false.  Can you test this with your changes ?

I think Integer is not castable to boolean. I tried these queries:
1. select cast(0 as boolean) from cp.`tpch/region.parquet` => Calcite complains: SqlValidatorException: Cast function cannot convert value of type INTEGER to type BOOLEAN; we can bypass calcite by this: cast 0 to ANY firstly as follows:
2. select cast(cast(0 as ANY) as boolean) from cp.`tpch/region.parquet` => IllegalArgumentException: Invalid value for boolean: 0

I also checked Casts.tdd, which does not have integer to boolean cast function.


- Sean Hsuan-Yi


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/32591/#review78299
-----------------------------------------------------------


On March 27, 2015, 9:44 p.m., Sean Hsuan-Yi Chu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/32591/
> -----------------------------------------------------------
> 
> (Updated March 27, 2015, 9:44 p.m.)
> 
> 
> Review request for drill and Aman Sinha.
> 
> 
> Bugs: DRILL-2590
>     https://issues.apache.org/jira/browse/DRILL-2590
> 
> 
> Repository: drill-git
> 
> 
> Description
> -------
> 
> DRILL-2590: In implicit casting rule, make boolean to be implicitly castable from boolean only
> 
> 
> Diffs
> -----
> 
>   exec/java-exec/src/main/java/org/apache/drill/exec/resolver/TypeCastRules.java 8fc6612 
>   exec/java-exec/src/test/java/org/apache/drill/TestUnionAll.java 520c204 
>   exec/java-exec/src/test/resources/store/json/booleanData.json PRE-CREATION 
>   exec/java-exec/src/test/resources/store/json/intData.json PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/32591/diff/
> 
> 
> Testing
> -------
> 
> QA, unit tests
> 
> 
> Thanks,
> 
> Sean Hsuan-Yi Chu
> 
>