在 cqlsh 我试图插入一条记录:
INSERT INTO data
(order_id,order_ts,transaction_id,transaction_discount,transaction_qty,
transaction_total,
product_category,product_profit,product_upc,product_name,product_price,
product_distributor,
store_id,store_name,store_state,store_region,id)
values ('YBC8RWE18',1368438171000,'LQKLVVI4E', 0, 1, 140.72,
'Office Supplies', 12.42,
'YT8899H3357', 'Casio USB Model FX-9860GII', 140.72, 'QR0', '2YOYWMR28Q',
'BigLots', 'AZ',
'Southwest', 2259a88e-b62d-4625-a86e-b86d77418a34 );
看起来不错,但我遇到了一个数字异常:
Caused by: java.lang.NumberFormatException: Zero length BigInteger
at java.math.BigInteger.<init>(BigInteger.java:190)
at org.apache.cassandra.serializers.DecimalSerializer.deserialize(DecimalSerializer.java:41)
at org.apache.cassandra.serializers.DecimalSerializer.deserialize(DecimalSerializer.java:26)
at org.apache.cassandra.db.marshal.AbstractType.compose(AbstractType.java:142)
at org.apache.cassandra.db.marshal.DecimalType.compare(DecimalType.java:46)
看起来DecimalSerializer.deserialize
真正的问题在这里。如果我尝试将小数括在引号中(我想值得一试),我会得到:
Bad Request: Invalid STRING constant (140.72) for product_price of type decimal
所以这没有帮助。我需要做什么才能插入小数?我应该发布 COLUMFAMILY def 吗?
这是描述表:
CREATE TABLE data (
id uuid,
order_id text,
order_ts timestamp,
product_category text,
product_distributor text,
product_name text,
product_price decimal,
product_profit decimal,
product_upc text,
store_id text,
store_name text,
store_region text,
store_state text,
transaction_discount decimal,
transaction_id text,
transaction_qty int,
transaction_total decimal,
PRIMARY KEY (id)
)
如果我去掉 140.72 左右的引号,我会得到:Request did not complete within rpc_timeout.
并且日志会显示deserialize
错误。如果我尝试只插入几列,那很好——直到我尝试插入 product_price 字段。