[
https://issues.apache.org/jira/browse/CALCITE-4871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17879399#comment-17879399
]
xiong duan commented on CALCITE-4871:
-------------------------------------
This issue was fixed in CALCITE-6380.
[b2224a8b9f|https://github.com/apache/calcite/commit/b2224a8b9f246b52b01ab24a591562b69b22fca7]
has some tests to verify it. Thanks for the review [~mbudiu].
> 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
> 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)