Here is my Cassandra schema, using Datastax Enterprise
CREATE KEYSPACE applications
WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1};
USE applications;
CREATE TABLE events(
bucket text,
id timeuuid,
app_id uuid,
event text,
PRIMARY KEY(bucket, id)
);
I want to FILTER in PIG by app_id
(TimeUUID) and id
(UUID), here is my Pig script.
events = LOAD 'cql://applications/events'
USING CqlStorage()
AS (bucket: chararray, id: chararray, app_id: chararray, event: chararray);
result = FOREACH events GENERATE bucket, id, app_id;
DESCRIBE result;
DUMP result;
Here is the result
result: {bucket: chararray,id: chararray,app_id: chararray}
(2014-02-28-04,?O]??4??p??M?,;??F? (|?Mb) \n
(2014-02-28-04,?O??4??p??M?,?h^@?E????)
(2014-02-28-04,?V???4??p??M?,;??F? (|?Mb)
(2014-02-28-04,?W?0?4??p??M?,?h^@?E????)
(2014-02-28-04,?X^p?4??p??M?,?h^@?E????)
Notice, the app_id
, and id
fields are binary and I need to filter by some UUID, any suggestions?
You need use a UDF to convert the binary bytes of UUID/TimeUUID to chararray. Don't try to define it as chararray directly like AS (bucket: chararray, id: chararray, app_id: chararray, event: chararray);
Or you can use https://github.com/cevaris/pig-dse/blob/master/src/main/java/com/dse/pig/udfs/AbstractCassandraStorage.java which convert UUID/TimeUUID to String
File a Cassandra ticket if you think it's good to convert UUID to string as default.