question

tufz_usama avatar image
tufz_usama asked Erick Ramirez answered

Only 280 rows returned after inserting 1030

I am trying to insert 1030 rows in cassandra database but but after the a successful execution of code when i check for entries, then it shows only 280 rows.

I have attached images showing how i am inserting the rows and the number of rows i got into database.

db.jpg


db2.jpg

cql
db.jpg (51.4 KiB)
db2.jpg (41.1 KiB)
3 comments
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

steve.lacerda avatar image steve.lacerda ♦ commented ·
Please provide the table schema. I'm wondering if you're overwriting rows somehow instead of inserting new rows.
1 Like 1 ·
tufz_usama avatar image tufz_usama steve.lacerda ♦ commented ·

This is the link to csv file which i am trying to insert Cassandra DB


I have shared the link of file above. Please check and share the solution to make it work.

0 Likes 0 ·
tufz_usama avatar image tufz_usama steve.lacerda ♦ commented ·

I have tried again using csv reader to read and then using query to insert the data. Again i am getting only 280 rows.


db3.jpg

0 Likes 0 ·
db3.jpg (49.3 KiB)
steve.lacerda avatar image
steve.lacerda answered

I would like to post the answer then, which is what I assumed. Your primary key was not unique for each entry and so the entries were overwriting and not inserting new rows. That is easy to fix, just change the primary key so that all values in the primary key are unique.

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered

The issue you described sounds like you got the data model wrong. In Cassandra, there is a big difference between number of records (CQL partitions) and rows.

A CQL partition can contain one or more rows depending on the data model. For example, a table with a simple primary key (there is only one column) will only ever have one row. Whereas a table with a compound primary key (more than one column) can have one or more rows.

In your case, it sounds like you've defined the table with a compound primary key instead of a simple primary key so you are not getting the results you expected. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.