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

Andrés de la Peña commented on CASSANDRA-14170:
-----------------------------------------------

Overall the patch looks good to me. However, the new test 
[{{testNoLossOfPrecisionForCastToDecimal}}|https://github.com/blerer/cassandra/blob/4b1f5804837ae3164bb183fcb62077683621651a/test/unit/org/apache/cassandra/cql3/functions/CastFctsTest.java#L205-L212]
 misses the {{@Test}} annotation. Indeed, it fails due to [a column names 
mismatch at the insert 
statement|https://github.com/blerer/cassandra/blob/4b1f5804837ae3164bb183fcb62077683621651a/test/unit/org/apache/cassandra/cql3/functions/CastFctsTest.java#L208].
 I think it should be [this 
way|https://github.com/adelapena/cassandra/commit/be44415a3f61e13720889cfd44482ee1142e8c1d].
 If it's ok for you it can be addressed during commit.

Nitpick: there is a misssed blank line in {{getDecimalConversionFunction}} 
JavaDoc, 
[here|https://github.com/adelapena/cassandra/commit/86f8121f95adb60eef85edbcaf9fb3917ef5207f].

> Loss of digits when doing CAST from varint/bigint to decimal
> ------------------------------------------------------------
>
>                 Key: CASSANDRA-14170
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-14170
>             Project: Cassandra
>          Issue Type: Bug
>         Environment: Tested with Cassandra 3.11.1 but this issue is present 
> since the implementation of cast functions.
>            Reporter: Daniel Fiala
>            Assignee: Benjamin Lerer
>            Priority: Minor
>
> Cast functions from numeric types to decimal type are implemented as 
> conversion to double first and then from double to decimal: 
> [https://github.com/apache/cassandra/compare/trunk...blerer:10310-3.0#diff-6aa4a8f76df6c30c5bb4026b8c9251eeR80].
> This can cause loss of digits for big values stored in varint or bigint. It 
> is probably unexpected because decimal can store such values precisely.
> Examples:
> {{cqlsh> CREATE TABLE cast_bigint_test(k int PRIMARY KEY, bigint_clmn 
> bigint);}}
>  {{cqlsh> INSERT INTO cast_bigint_test(k, decimal_clmn) VALUES(2, 
> 9223372036854775807);}}
>  {{cqlsh> SELECT CAST(bigint_clmn AS decimal) FROM cast_bigint_test;}}
>  {{cast(bigint_clmn as decimal)}}
>  {{------------------------------}}
>  {{9.223372036854776E+18}}
>  {{(1 rows)}}
> {{cqlsh> CREATE TABLE cast_varint_test (k int PRIMARY KEY, varint_clmn 
> varint);}}
>  {{cqlsh> INSERT INTO cast_varint_test(k, varint_clmn) values(2, 
> 1234567890123456789);}}
>  {{cqlsh> SELECT CAST(varint_clmn AS decimal) FROM cast_varint_test;}}
>  {{cast(varint_clmn as decimal)}}
>  {{------------------------------}}
> 1.23456789012345677E+18
>  {{(1 rows)}}
>  



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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to