Closed sonyjv closed 10 years ago
@sonyjv Will be great if you could run it in Debug mode and show the insert query being executed in both cases.
Thanks Rohit for the quick response.
In case of 4 column composite key, for the table CREATE TABLE Search ( search_id int, category text, listing_id int, monthYear text, distance double, term text, PRIMARY KEY ((category, listing_id), monthYear, search_id) );
the query generated is
update search set distance = ?, term = ? WHERE "category" = ? AND "listing_id" = ? AND "monthyear" = ? AND "search_id" = ?
For 3 column composite key, for the table CREATE TABLE Search ( search_id int, category text, listing_id int, monthYear text, distance double, term text, PRIMARY KEY ((category, listing_id), search_id) );
the generated query is
update search set monthYear = ?, distance = ?, name = ? WHERE "category" = ? AND "listing_id" = ? AND "search_id" = ?
The latter is working fine and records are inserted.
category | listing_id | search_id | distance | monthyear | term ----------------------+------------+-----------+----------+-----------+------------------ Restaurants | 3554276 | 1001 | 1.47 | 2001-02 | Cocktail Lounges Japanese Restaurants | 223123 | 1001 | 8.44 | 2001-02 | Cocktail Lounges Restaurants | 4618106 | 1001 | 4.22 | 2001-02 | Cocktail Lounges Restaurants | 4618118 | 1001 | 6.69 | 2001-02 | Cocktail Lounges
@Rohit, I found the problem. It was a mistake from my side. I had defined implicit keyMarshaller as implicit def keyMarshaller(x: (SearchedCategory)): CQLRowKeyMap = Map("category" -> x.category, "listing_id" -> x.listingID, "monthYear" -> x.monthYear, "search_id" -> x.searchID.toInt)
In Cassandra column name "monthYear" was created as "monthyear". On changing keyMarshaller to
implicit def keyMarshaller(x: (SearchedCategory)): CQLRowKeyMap = Map("category" -> x.category, "listing_id" -> x.listingID, "monthyear" -> x.monthYear, "search_id" -> x.searchID.toInt)
the issue got resolved.
Thanks again for your help and for the wonderful library. We are going to use it for our implementation. :)
@sonyjv I'm not the Rohit you are looking for. :)
First of all, thank you for this wonderful library. It is a great work.
While using this library, I have an issue in updating table with composite key.
Following is the Cassandra table.
From a Spark job I am trying to insert some records using Calliope 0.9.0-U1-C2-EA. The relevant code is as below.
I am getting the following exception (@cqlsh the query works without any problem). If I remove one column from the composite key (change the no. of keys from 4 to 3) it works without any issue.
Could you please be able to guide in resolving the issue.