In CQL Updates and Inserts are the same thing.

You need to convert your insert statements to UPDATE

Here is a quick example loading from a JSON file, into two cassandra tables

Notice the the output query is URL Encoded.




a = load 'barcode_uuid_mapping_current.json'
        using JsonLoader('uuidMapping:{(barcode:chararray,uuid:chararray)}');

result = foreach a GENERATE FLATTEN(uuidMapping); 


result = foreach a GENERATE FLATTEN(uuidMapping);

data_to_insert = FOREACH result GENERATE 
         TOTUPLE(
                 TOTUPLE('barcode',barcode) 
                 ),
          TOTUPLE( uuid ) ;
STORE data_to_insert INTO 
'cql://tcgadata/barcode_to_uuid?output_query=update%20barcode_to_uuid%20set%20uuid%20%3D%20%3F'
 USING CqlStorage();

data_to_insert = FOREACH result GENERATE 
         TOTUPLE(
                 TOTUPLE('uuid',uuid) 
                 ),
          TOTUPLE( barcode ) ;
STORE data_to_insert INTO 
'cql://tcgadata/uuid_to_barcode?output_query=update%20uuid_to_barcode%20set%20barcode%20%3D%20%3F'
 USING CqlStorage();


There are some other examples here:
http://www.datastax.com/dev/blog/cql3-table-support-in-hadoop-pig-and-hive

and

http://www.schappet.com/pig_cassandra_bulk_load/




On May 20, 2014, at 10:02 PM, Kevin Burton <bur...@spinn3r.com> wrote:

> It seems that CqlStorage can't perform INSERTs when using pig.  IS there a 
> reason for this?
> 
> Here's the relevant code from 2.0.7:
> 
>             String cqlQuery = CqlConfigHelper.getOutputCql(conf).trim();
>             if (cqlQuery.toLowerCase().startsWith("insert"))
>                 throw new UnsupportedOperationException("INSERT with 
> CqlRecordWriter is not supported, please use UPDATE/DELETE statement");
> 
> … It seems to me that a DELETE and UPDATE is significantly less important 
> than INSERT.
> 
> My use case is that I'm using pig to build a custom secondary index, and then 
> loading it back into cassandra.
> 
> -- 
> 
> Founder/CEO Spinn3r.com
> Location: San Francisco, CA
> Skype: burtonator
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> 
> War is peace. Freedom is slavery. Ignorance is strength. Corporations are 
> people.
> 

Reply via email to