我有一个要复制到cassandra表中的csv文件。这是模式:
CREATE TABLE keyspace.mytable (
A int,
B text,
C text,
uuid text,
D text,
E boolean,
F text,
G text,
PRIMARY KEY (A, B, C, uuid)
) WITH CLUSTERING ORDER BY (B ASC, C ASC, uuid ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'unchecked_tombstone_compaction': 'true', 'tombstone_compaction_interval': '1200', 'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.0
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.1
AND speculative_retry = '99.0PERCENTILE';
当我尝试使用此复制命令时遇到此问题:
COPY keyspace.mytable FROM 'data.csv' ;
<ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:244 no viable alternative at input ',' (...769,'2015-01-22','XYZ, QRT Campaign Yay','9e1bda3c-f547-4d8f-af5d-4c0649697ca8','true',[ABC],...)">
Aborting import at record #202. Previously inserted records are still present, and some records after that may be present as well.
答案 0 :(得分:0)
所以这行有你的线索...
[Syntax error in CQL query] message="line 1:244 no viable alternative at input ','
(...769,'2015-01-22','XYZ, QRT Campaign Yay','9e1bda3c-f547-4d8f-af5d-4c0649697ca8',
'true',[ABC],...)">
Aborting import at record #202.
看来,'2015-01-22','XYZ, QRT Campaign Yay',
所在的行缺少单引号。这表明COPY
很难解析,因此我认为您文件中的行在QRT Campaign Yay'
字段中有一个额外的单引号。
您可以尝试的一件事是设置一个不同的QUOTE
标识符;但这实际上取决于文件的外观。快速解决方案是编辑该行,然后删除或转义该单引号。