[jira] [Commented] (DRILL-520) ceiling/ceil and floor functions return decimal value instead of an integer

2018-03-15 Thread Karthikeyan Manivannan (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16401459#comment-16401459
 ] 

Karthikeyan Manivannan commented on DRILL-520:
--

This cannot be fixed simply by changing the return type of the builtin 
functions (as suggested in the attached patch) because floating point types 
(Float4, Float8) have a range that is beyond what can be represented in any 
integer type, even in BigInt.

This is what happens if the patch (change the outputType of ceil/floor to Int 
and use a (int) cast to return the value of java.lang.Math.ceil/floor) is 
applied

0: jdbc:drill:zk=local> select floor(cast('34028.5' as float));

 

| 34028  |

1 row selected (0.157 seconds)

0: jdbc:drill:zk=local> select floor(cast('340280.5' as float));   <--- too 
big to represent as Int

| 2147483647  |  <- Int max

A similar overflow will happen even if a BigInt output type and a 'double' cast 
is used.

I looked up how ProsgreSQL implements ceil/floor:
|Name|Return Type|Description|Example|Result|
|{{ceil(dp}} or {{numeric}})|same as input)|nearest integer greater than or 
equal to argument|{{ceil(-42.8)}}|{{-42}}|
|{{floor(dp}} or {{numeric}})|(same as input)|nearest integer less than or 
equal to argument|{{floor(-42.8)}}|{{-43}}|

where 

_*dp*_ is a double precision 8byte floating-point number
 _*numeric*_ is numeric [ (p, s) ] exact numeric of selectable precision

I am not sure how a the dp/numeric return type is returned as an Int

I think the way to fix this in Drill would be to use BigDecimal as the return 
type. 

 

 

> ceiling/ceil and floor functions return decimal value instead of an integer
> ---
>
> Key: DRILL-520
> URL: https://issues.apache.org/jira/browse/DRILL-520
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Functions - Drill
>Affects Versions: 1.0.0
>Reporter: Krystal
>Assignee: Karthikeyan Manivannan
>Priority: Critical
> Fix For: Future
>
> Attachments: DRILL-520.patch
>
>
> Ran the following queries in drill:
> 0: jdbc:drill:schema=dfs> select ceiling(55.8) from dfs.`student` where 
> rownum=11;
> ++
> |   EXPR$0   |
> ++
> | 56.0   |
> ++
> 0: jdbc:drill:schema=dfs> select floor(55.8) from dfs.`student` where 
> rownum=11;
> ++
> |   EXPR$0   |
> ++
> | 55.0   |
> ++
> The same queries executed from oracle, postgres and mysql returned integer 
> values of 56 and 55.
> Found the following description of the two functions from 
> http://users.atw.hu/sqlnut/sqlnut2-chp-4-sect-4.html :
> Ceil/Ceiling:
> Rounds a noninteger value upwards to the next greatest integer. Returns an 
> integer value unchanged.
> Floor:
> Rounds a noninteger value downwards to the next least integer. Returns an 
> integer value unchanged.



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


[jira] [Commented] (DRILL-520) ceiling/ceil and floor functions return decimal value instead of an integer

2017-02-21 Thread Krystal (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15876705#comment-15876705
 ] 

Krystal commented on DRILL-520:
---

Tried the tests on the latest 1.10 master and the results are still the same as 
originally reported. 

> ceiling/ceil and floor functions return decimal value instead of an integer
> ---
>
> Key: DRILL-520
> URL: https://issues.apache.org/jira/browse/DRILL-520
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Functions - Drill
>Affects Versions: 1.0.0
>Reporter: Krystal
>Assignee: Jinfeng Ni
>Priority: Critical
> Fix For: Future
>
> Attachments: DRILL-520.patch
>
>
> Ran the following queries in drill:
> 0: jdbc:drill:schema=dfs> select ceiling(55.8) from dfs.`student` where 
> rownum=11;
> ++
> |   EXPR$0   |
> ++
> | 56.0   |
> ++
> 0: jdbc:drill:schema=dfs> select floor(55.8) from dfs.`student` where 
> rownum=11;
> ++
> |   EXPR$0   |
> ++
> | 55.0   |
> ++
> The same queries executed from oracle, postgres and mysql returned integer 
> values of 56 and 55.
> Found the following description of the two functions from 
> http://users.atw.hu/sqlnut/sqlnut2-chp-4-sect-4.html :
> Ceil/Ceiling:
> Rounds a noninteger value upwards to the next greatest integer. Returns an 
> integer value unchanged.
> Floor:
> Rounds a noninteger value downwards to the next least integer. Returns an 
> integer value unchanged.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-520) ceiling/ceil and floor functions return decimal value instead of an integer

2017-02-20 Thread Kunal Khatua (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15875105#comment-15875105
 ] 

Kunal Khatua commented on DRILL-520:


[~knguyen] Can this bug be verified and closed? It looks like this was not 
applied. Assign it to [~jni], if we don't see the fix. 

> ceiling/ceil and floor functions return decimal value instead of an integer
> ---
>
> Key: DRILL-520
> URL: https://issues.apache.org/jira/browse/DRILL-520
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Functions - Drill
>Affects Versions: 1.0.0
>Reporter: Krystal
>Assignee: Mehant Baid
>Priority: Critical
> Fix For: Future
>
> Attachments: DRILL-520.patch
>
>
> Ran the following queries in drill:
> 0: jdbc:drill:schema=dfs> select ceiling(55.8) from dfs.`student` where 
> rownum=11;
> ++
> |   EXPR$0   |
> ++
> | 56.0   |
> ++
> 0: jdbc:drill:schema=dfs> select floor(55.8) from dfs.`student` where 
> rownum=11;
> ++
> |   EXPR$0   |
> ++
> | 55.0   |
> ++
> The same queries executed from oracle, postgres and mysql returned integer 
> values of 56 and 55.
> Found the following description of the two functions from 
> http://users.atw.hu/sqlnut/sqlnut2-chp-4-sect-4.html :
> Ceil/Ceiling:
> Rounds a noninteger value upwards to the next greatest integer. Returns an 
> integer value unchanged.
> Floor:
> Rounds a noninteger value downwards to the next least integer. Returns an 
> integer value unchanged.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)