Search code examples
javahadoopcassandracqloutputformat

Using CqlOutputFormat for INSERT statement


I'm fairly new to Cassandra. I'm using hadoop to bulk load data into a cassandra cluster using CqlOutputFormat. I'm unable to find sufficient examples in internet to tailor it to my usecase.

I'm specifically using it to insert data into the cluster using the statement ,

insert into pinseries (pin, timeseries) values(?, ?)

I'm not sure how the context.write() should look like to make this work. There seems to be enough examples to see how it should work for an update statement (The wordcount from examples will do). But can someone tell me how to use that in insert mode?


Solution

  • The CqlRecordWriter used by the CqlOutputFormat doesn't support insert statements only update statements so you will need to use update to insert your data. Along the lines of:

    update pinseries set timeseries = ? where pin = ?
    

    I'm assuming that pin is your primary key.