【发布时间】:2015-11-23 00:11:31
【问题描述】:
我正在尝试将 CSV 文件导入 Cassandra 表,但是我遇到了问题。 插入成功后,至少 Cassandra 是这么说的,我还是看不到任何记录。这里有更多细节:
qlsh:recommendation_engine> COPY row_historical_game_outcome_data FROM '/home/adelin/workspace/docs/re_raw_data2.csv' WITH DELIMITER='|';
2 rows imported in 0.216 seconds.
cqlsh:recommendation_engine> select * from row_historical_game_outcome_data;
customer_id | game_id | time | channel | currency_code | game_code | game_name | game_type | game_vendor | progressive_winnings | stake_amount | win_amount
-------------+---------+------+---------+---------------+-----------+-----------+-----------+-------------+----------------------+--------------+------------
(0 rows)
cqlsh:recommendation_engine>
这就是我的数据的样子
'SomeName'|673|'SomeName'|'SomeName'|'TYPE'|'M'|123123|0.20000000000000001|0.0|'GBP'|2015-07-01 00:01:42.19700|0.0|
'SomeName'|673|'SomeName'|'SomeName'|'TYPE'|'M'|456456|0.20000000000000001|0.0|'GBP'|2015-07-01 00:01:42.19700|0.0|
这是 cassandra 版本 apache-cassandra-2.2.0
编辑:
CREATE TABLE row_historical_game_outcome_data (
customer_id int,
game_id int,
time timestamp,
channel text,
currency_code text,
game_code text,
game_name text,
game_type text,
game_vendor text,
progressive_winnings double,
stake_amount double,
win_amount double,
PRIMARY KEY ((customer_id, game_id, time))
) WITH bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
我还按照 uri2x 的建议尝试了以下方法
但还是一无所获:
select * from row_historical_game_outcome_data;
customer_id | game_id | time | channel | currency_code | game_code | game_name | game_type | game_vendor | progressive_winnings | stake_amount | win_amount
-------------+---------+------+---------+---------------+-----------+-----------+-----------+-------------+----------------------+--------------+------------
(0 rows)
cqlsh:recommendation_engine> COPY row_historical_game_outcome_data ("game_vendor","game_id","game_code","game_name","game_type","channel","customer_id","stake_amount","win_amount","currency_code","time","progressive_winnings") FROM '/home/adelin/workspace/docs/re_raw_data2.csv' WITH DELIMITER='|';
2 rows imported in 0.192 seconds.
cqlsh:recommendation_engine> select * from row_historical_game_outcome_data;
customer_id | game_id | time | channel | currency_code | game_code | game_name | game_type | game_vendor | progressive_winnings | stake_amount | win_amount
-------------+---------+------+---------+---------------+-----------+-----------+-----------+-------------+----------------------+--------------+------------
(0 rows)
【问题讨论】:
-
你能告诉我们你的
DESCRIBE TABLE吗? -
这里我已经添加了表格描述。
-
您的列顺序似乎与 CSV 文件中的不同(第一列不是 int,第三列不是日期,依此类推)。尝试使用 COPY 和列名来匹配 CSV 文件的顺序。
-
相同的结果没有成功:(
-
你能展示你的新
COPY子句吗?
标签: csv cassandra cql cassandra-2.0 cqlsh