0

I am trying to write data to Cassandra CQL 3 Table using:

STORE G INTO 'cql://keyapse/col_family?output_query=not sure what goes here' USING CqlStorage();

What does the output_query look like:

UPDATE col_family SET col1=$0, col2=$3 WHERE KEY=$2

e90jimmy
  • 272
  • 1
  • 2
  • 11

3 Answers3

1

You need to take care on both: the storage URL and the data preparation. This is an example that should work.

Suppose you need to insert data in the following structure:

CREATE TABLE example (
  row_id text PRIMARY KEY,

  value1 text,

  value2 int
);

You need to prepare the data like this:

data_to_insert = FOREACH some_set_of_data GENERATE 

    TOTUPLE(TOTUPLE('row_id',row_id)), TOTUPLE(value1, value2) ;

Finally the storing statement will be:

STORE data_to_insert INTO 'cql://my/example?output_query=update example set value1 @ # , value2 @ #' USING CqlStorage();
Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75
  • Kernald, can you add this to the comments on, http://www.datastax.com/dev/blog/cql3-table-support-in-hadoop-pig-and-hive. Or I would be happy too for you. – e90jimmy Aug 08 '13 at 13:04
  • Cassandra 1.2.10 breaks this method of creating the statement. It now expects the query to be URL encoded. Your example would become: STORE data_to_insert INTO 'cql://my/example?output_query=update+example+set value1+%3D+%3F+,+value2+%3D+%3F' USING CqlStorage(); – Chad Sep 23 '13 at 15:16
0

This blog has some details, but no specific examples: http://www.datastax.com/dev/blog/cql3-table-support-in-hadoop-pig-and-hive

Alex
  • 1
0

I wrote up a brief how to on using PIG as a Data loader for Cassandra using CQL3.

http://www.schappet.com/pig_cassandra_bulk_load

Basic setup includes the info from @Kernald

STORE data_to_insert INTO
  'cql://myschema/example?output_query=update example set value1 @ #,value2 @ #' USING CqlStorage();
e90jimmy
  • 272
  • 1
  • 2
  • 11