CassandraPig店

w6mmgewl  于 2021-06-24  发布在  Pig
关注(0)|答案(1)|浏览(272)

我有一张Cassandra的table

CREATE COLUMN FAMILY users
WITH comparator = UTF8Type
AND key_validation_class=UTF8Type
AND column_metadata = [
{column_name: full_name, validation_class: UTF8Type}
{column_name: email, validation_class: UTF8Type}
{column_name: state, validation_class: UTF8Type}
{column_name: gender, validation_class: UTF8Type}
{column_name: birth_year, validation_class: LongType}
];

并有一个Pig脚本如下

rows = LOAD 'cassandra://hwh_tracking/users' USING org.apache.cassandra.hadoop.pig.CassandraStorage();
emailgroup = group rows by email;
dump emailgroup;

现在输出是这样的

((email,r@gmail.com),{(rrr24,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr10,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr20,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr23,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr9,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr8,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr22,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr21,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{})})
((email,zzzz@gmail.com),{(rrr0,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr6,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr7,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr3,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr1,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr5,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr4,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{}),(rrr2,(full_name,rachana),email,(state,ca),(birth_year,2013),(gender,female),{})})

现在我想把输出存储回cassandra,但不知道怎么做。
感谢您的帮助。

jtjikinw

jtjikinw1#

pigServer.registerQuery("likes = FILTER rows by vote_type.value eq 'like' AND rating.value > 5;");

//pigServer.registerQuery("dislikes_extras = FILTER rows by vote_type.value eq 'dislike' AND COUNT(columns) > 0;");

pigServer.registerQuery("STORE likes INTO 'cassandra://PigTest/CopyOfSomeApp' USING org.apache.cassandra.hadoop.pig.CassandraStorage();");

//pigServer.registerQuery("STORE dislikes_extras INTO 'cassandra://PigTest/CopyOfSomeApp' USING org.apache.cassandra.hadoop.pig.CassandraStorage();");

相关问题