[
https://issues.apache.org/jira/browse/CALCITE-4871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17879728#comment-17879728
]
xiong duan commented on CALCITE-4871:
-------------------------------------
Cast.iq added in
[acf4209e0d|https://github.com/apache/calcite/commit/acf4209e0d53f17818c17735235d8762a2d7adb4].
> 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: xiong duan
> Assignee: xiong duan
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.38.0
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> 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.20.10#820010)