We are performing tests for an aggregator application, and are observing some differences on how data is being displayed for certain datatypes (double and decimal so far) between Cassandra and YugabyteDB.
For transaction
table, market_value
column with double datatype – our Spark application writes data (original value is converted into BigDecimal in Java) and the RDD prints value as 1000000.01
. Once this row is written into the database, Cassandra shows this value as expected, whereas in YB, value in YCQLSH
it shows up as 1e+06. Even our API that reads the data gets it as 1e+06 .
YB version – 2.1.6.2
YCQL java driver – 4.6.0-yb-6
Any thoughts or suggestions on what could be possible reasons for this value to be displayed differently?
This is our schema:
CREATE TABLE IF NOT EXISTS transaction (
account_id int,
transaction_id text,
quantity double,
price double,
market_value double,
PRIMARY KEY ((account_id), transaction_id)
) WITH CLUSTERING ORDER BY (transaction_id ASC);
Those non-integer types like DECIMAL
, DOUBLE
, FLOAT
are inexact numbers. DOUBLE
and FLOAT
have limits on their precision (8 vs 4 bytes) and DECIMAL
is an arbitrary precision type that does not have limits on the amount of precision. You can CAST(field as TEXT)
to show it “expanded” to 1000000 instead of 1E+06.
DOUBLE
has a limit of 15 digits after the decimal point and FLOAT
has a limit 7 digits of precision.