DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

chandrasekar.b03_190734 avatar image
chandrasekar.b03_190734 asked Erick Ramirez answered

Can we have same where clause conditions for different table partitions?

(The scenario was from katacoda>Apache Cassandra for Developers>Atomicity & Batches) Let's consider two different tables of different partitions....

CREATE TABLE ratings_by_user (
    email TEXT,
    title TEXT,
    year INT,
    rating INT,
    PRIMARY KEY ((email), title, year)
)
CREATE TABLE ratings_by_movie (
    title TEXT,
    year INT,
    email TEXT,
    rating INT,
    PRIMARY KEY ((title, year), email)
)

After doing some record insertions, I try to read from the tables using the below query:

select * from ratings_by_movie where title='Alice in Wonderland' and year=2018 and email='joe@datastax.com';
select * from ratings_by_user where title='Alice in Wonderland' and year=2018 and email='joe@datastax.com';

For both select statements, the result was same,

Title = 'Alice in Wonderland'
Year = 2018
Email = 'joe@datastax.com'

My question is how could the where clause conditions be same for the both different tables of different partitions and why error is not thrown here??? (I have also included a screenshot here for the scenario where I experienced the same)

batches.jpg

cql
batches.jpg (394.1 KiB)
10 |1000 characters needed characters left characters exceeded

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

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

Yes, you can as long as you specify the partition key plus the relevant clustering keys.

Don't confuse it with the ordering of columns in the filter because it doesn't matter. What matters is that you specify the required columns. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

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