Cassandra:无法从csv导入null值 [英] Cassandra: Unable to import null value from csv
问题描述
我试图导入csv文件到Cassandra。 csv文件已从Postgres生成,并且包含一些空值。
I am trying to import a csv file to Cassandra. The csv file has been generated from Postgres and it contains some null values.
Cassandra版本:
Cassandra version:
[cqlsh 5.0.1 | Cassandra 3.5 | CQL spec 3.4.0 |本地协议v4]
[cqlsh 5.0.1 | Cassandra 3.5 | CQL spec 3.4.0 | Native protocol v4]
我使用此查询导入:
复制报告
(id,name,user_id,user_name,template_id,gen_epoch,exp_epoch,file_name,format,refile_size,is_sch,job_id,status,status_msg)
/reports.csv'with NULL =''and header = true and DELIMITER =
',';
copy reports (id,name,user_id,user_name,template_id,gen_epoch,exp_epoch,file_name,format,refile_size,is_sch,job_id,status,status_msg) from '/home/reports.csv' with NULL='' and header=true and DELIMITER = ',';
收到此错误:
无法导入66行:ParseError - 无效的文字int()与
base 10: ',放弃没有重试
Failed to import 66 rows: ParseError - invalid literal for int() with base 10: '', given up without retries
但是,当我将所有的空值改为某个随机值时,使用相同的命令。我已经尝试过在互联网上找到的所有解决方案。
请指教。
However, when I changed all the null values to some random value, I was able to import that row using the same command. I have already tried all the solutions I found on internet. Please advise.
推荐答案
这看起来像一个Cassandra错误(参见 https://issues.apache.org/jira/browse/CASSANDRA-11549 )。我还没有能够找到一种方式让Cassandra接受null。你可能需要坚持一个解决方法,现在用一些哨兵的值替换null。
This looks like a Cassandra bug (see https://issues.apache.org/jira/browse/CASSANDRA-11549). I haven't been able to find a way to get Cassandra to accept the nulls. You may have to stick with a workaround for now substitute some sentinel value for the nulls.
这篇关于Cassandra:无法从csv导入null值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!