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

duan xiong updated CALCITE-4871:
--------------------------------
    Description: 
In calcite. The precision and scale can't work. 

1) Add judgment in decimal type precision and scale parameter(When have illegal 
value need to throw an exception):

SQL EXAMPLES:
{code:java}
cast(155.36 as decimal(0,0)){code}
In Postgresql:
{noformat}
ERROR: NUMERIC precision 0 must be between 1 and 1000{noformat}
In Calcite:
{noformat}
EXPR$0=155.36{noformat}
2) To make sure return the right answer。

SQL EXAMPLES:
{code:java}
cast(155.36 as decimal(4,1)){code}
In Postgresql:
{code:java}
EXPR$0=155.4{code}
In Calcite:
{code:java}
EXPR$0=155.36{code}
The problem exists in casting different data to decimal.

  was:
In calcite. The precision and scale can't work. 

1) Add judgment in decimal type precision and scale parameter(When have illegal 
value need to throw an exception):

SQL EXAMPLES:
{code:java}
cast(155.36 as decimal(0,0)){code}
In Postgresql:
{noformat}
ERROR: NUMERIC precision 0 must be between 1 and 1000{noformat}
In Calcite:
{noformat}
EXPR$0=155.36{noformat}
2) To make sure return the right answer。

SQL EXAMPLES:
{code:java}
cast(155.36 as decimal(4,1)){code}
In Postgresql:
{code:java}
EXPR$0=155.4{code}
In Calcite:
{code:java}
EXPR$0=155.36{code}
The problem exists in cast different di


> CAST a literal to DECIMAL type return wrong result
> --------------------------------------------------
>
>                 Key: CALCITE-4871
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4871
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.28.0
>            Reporter: duan xiong
>            Assignee: duan xiong
>            Priority: Major
>             Fix For: 1.29.0
>
>
> In calcite. The precision and scale can't work. 
> 1) Add judgment in decimal type precision and scale parameter(When have 
> illegal value need to throw an exception):
> SQL EXAMPLES:
> {code:java}
> cast(155.36 as decimal(0,0)){code}
> In Postgresql:
> {noformat}
> ERROR: NUMERIC precision 0 must be between 1 and 1000{noformat}
> In Calcite:
> {noformat}
> EXPR$0=155.36{noformat}
> 2) To make sure return the right answer。
> SQL EXAMPLES:
> {code:java}
> cast(155.36 as decimal(4,1)){code}
> In Postgresql:
> {code:java}
> EXPR$0=155.4{code}
> In Calcite:
> {code:java}
> EXPR$0=155.36{code}
> The problem exists in casting different data to decimal.



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

Reply via email to