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

Julian Hyde commented on CALCITE-4838:
--------------------------------------

The minimum fix for this task would we support DOWN as rounding mode, and throw 
if someone tries to set It to UP.

A more complete fix (or another JIRA case) would be to support both UP and 
DOWN. Consider the query {{select cast(cast(deptno) as double) / 10 as integer) 
from emp}}. Implementing that would affect Java code generation (if we are 
implementing using Enumerable) and also affect SQL generation (if EMP is a 
table from the JDBC adapter). We would probably need to know the rounding mode 
of the target DB. 

> add roundingMode in SqlConformance to document the rounding mode when  cast 
> an approximate numeric to int
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4838
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4838
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.27.0
>            Reporter: duan xiong
>            Assignee: duan xiong
>            Priority: Major
>
> According to the SQL Strandard about how to cast an approximate numeric to 
> int in different database have different RoundingMode. for example:
> In PostgreSQL、Mysql、Oracle(RoundingMode.HALF_UP):
> {code:java}
> select cast(5.1 as int) return 5
> select cast(5.5 as int) return 6
> {code}
> In Calcite、Sql Server 2008(RoundingMode.DOWN):
> {code:java}
> select cast(5.1 as int) return 5
> select cast(5.5 as int) return 5
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to