从cassandra加载复制但在查询时没有行

时间:2015-08-22 19:07:12

标签: cassandra

我正在尝试将数据加载到我的表中,但发生了一件奇怪的事情:

我创建了我的类型和表格:

create type OfferInfo ( contacted text, channel text, campaign_tp text, hit_home_date timestamp, campaign text, creative text)

create type prdInfo ( PRVCY_CALL int, PRVCY_SWP int, PRVCY_MAIL int, PRVCY_AFIL int, PRVCY_FCRA int, PRVCY_PIPE int, PRVCY_GLBA int);

CREATE TABLE CustPrvcyOffers2 ( ent_cust_id int PRIMARY KEY, prds map<text, frozen<prdInfo>>, offerhist map<text, frozen<OfferInfo>> );

然后我加载这样的数据:

cqlsh:custprod> copy CustPrvcyOffers2 from '/home/ec2-user/part-00000' WITH DELIMITER='|';

50 rows imported in 0.136 seconds.

我做了一个选择*并将其取回:

cqlsh:custprod> select * from CustPrvcyOffers2;

 ent_cust_id | offerhist | prds
-------------+-----------+------

(0 rows)

我怎么没有回来?

另外,我的平面文件如下所示:

104|{'CNSMR_DIRCT_SAVG': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}, 'CNSMR_DIRCT_CHKG': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}, 'CNSMR_DIRCT_OTHR': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}}|{'TF1501B': {contacted: 'Y', channel: 'EM', campaign_tp: 'NOTIFICATION', hit_home_date: '1/26/2015', campaign: 'OTHER', creative: 'Generic Tax Form Message'}}
109|{'CNSMR_DIRCT_CHKG': {PRVCY_CALL: 4, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 2}, 'CNSMR_DIRCT_SAVG': {PRVCY_CALL: 4, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 2}, 'CNSMR_DIRCT_OTHR': {PRVCY_CALL: 4, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 2}}|{'SSO_CP_1501A': {contacted: 'Y', channel: 'EM', campaign_tp: 'NOTIFICATION', hit_home_date: '1/14/2015', campaign: 'OTHER', creative: 'SSO Customer - complex'}}
105|{'CNSMR_LOCL_IM_CHKG': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}, 'CNSMR_CARD': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}, 'CNSMR_DIRCT_SAVG': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}}|{'EST201412998': {contacted: 'Y', channel: 'LIST', campaign_tp: 'STATEMENT', hit_home_date: '1/3/2015', campaign: 'STMT_MESSAGE', creative: 'Statement Message'}}
100|{'CNSMR_LOCL_IM_CHKG': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}, 'CNSMR_CARD': {PRVCY_CALL: 1, PRVCY_SWP: 1, PRVCY_MAIL: 1, PRVCY_AFIL: 1, PRVCY_FCRA: 1, PRVCY_PIPE: 1, PRVCY_GLBA: 1}}|{'UBERFB1504': {contacted: 'N', channel: 'List', campaign_tp: 'Upsell', hit_home_date: '4/23/2015', campaign: 'Project Uber', creative: 'Project Uber'}}

1 个答案:

答案 0 :(得分:1)

需要指定列顺序。

copy CustPrvcyOffers2 (ent_cust_id, prds, offerhist) from '/home/ec2-user/part-00000' WITH DELIMITER='|';

此外,日期格式错误的csv ...日期格式为m/d/yyyy且需要为yyyy-m-d