如何使用pig和cassandra cqlstorage删除数据

arknldoa  于 2021-06-21  发布在  Pig
关注(0)|答案(0)|浏览(162)

我试图删除数据Cassandra使用Pig。文档中仅显示“更新语句”:http://www.datastax.com/docs/datastax_enterprise3.1/solutions/about_pig. 也许唯一的方法就是创建一个“pig udf”来删除这些数据。
架构

CREATE KEYSPACE keyspace_test WITH replication = {'class':'SimpleStrategy', 'replication_factor':2};
CREATE TABLE user (name text,last_name text,adress text,PRIMARY KEY (name));
INSERT INTO user (name, last_name, adress) VALUES ('albert','griffith', 'street example1');
INSERT INTO user (name, last_name, adress) VALUES ('adam','garcia', 'street example2');

脚本Pig

users = LOAD 'cql://keyspace_test/user' USING CqlStorage();
user = filter users by name == 'adam';
data_to_delete = FOREACH user GENERATE TOTUPLE(TOTUPLE('name',name)),() ;
STORE data_to_delete INTO 'cql://keyspace_test/user?output_query=DELETE+FROM+keyspace_test.user' USING CqlStorage;

结果
尽管这表明一切正常,但它并没有删除Cassandra的数据:
输入:

Successfully read 2 records from: "cql://keyspace_test/user"

输出:

Successfully stored 1 records in: "cql://keyspace_test/user?output_query=DELETE+FROM+keyspace_test.user"

计数器:

Total records written : 1
Total bytes written : 0
Spillable Memory Manager spill count : 0
Total bags proactively spilled: 0
Total records proactively spilled: 0

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题