Friday, September 15, 2023

clustering key restrictions

 cqlsh:aug_space> select * from movies_by_ratings;


 age_rating | movie_id                             | genres                | release_date                    | title

------------+--------------------------------------+-----------------------+---------------------------------+-----------------

          5 | 41d8ffdf-fb1e-43d0-85ae-9c4f358f35c2 |                  null | 2023-09-09 18:27:16.646000+0000 |            null

          5 | 93762f96-005c-4bd9-8994-1a6454a91334 |                  null | 2023-09-09 18:27:16.646000+0000 |            null

          8 | 236d3970-97f1-4f24-9bb1-d657cc698dac | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 | Jurassic Park 2

          8 | 6ae5a279-36e0-49db-b39d-f9b582f082a3 | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 |       Avatar  2

          7 | d9573b24-02cb-49b4-91ba-c040c5a0127a | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 |          Avatar

          9 | 2e70b67b-e6f7-4cf3-9493-b8e21641094d | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 | Sturat Little 3

          9 | 41d8ffdf-fb1e-43d0-85ae-9c4f358f35c2 | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 | Sturat Little 2

          9 | 7b085f61-4202-4bd8-b84c-f2a46baf0853 | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 |   Sturat Little

          9 | 93762f96-005c-4bd9-8994-1a6454a91334 | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 |   Jurassic Park


(9 rows)

cqlsh:aug_space> select * from movies_by_ratings order by movie_id desc;

InvalidRequest: Error from server: code=2200 [Invalid query] message="ORDER BY is only supported when the partition key is restricted by an EQ or an IN."


cqlsh:aug_space> select * from movies_by_ratings where age_rating=9 order by movie_id asc;


 age_rating | movie_id                             | genres                | release_date                    | title

------------+--------------------------------------+-----------------------+---------------------------------+-----------------

          9 | 2e70b67b-e6f7-4cf3-9493-b8e21641094d | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 | Sturat Little 3

          9 | 41d8ffdf-fb1e-43d0-85ae-9c4f358f35c2 | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 | Sturat Little 2

          9 | 7b085f61-4202-4bd8-b84c-f2a46baf0853 | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 |   Sturat Little

          9 | 93762f96-005c-4bd9-8994-1a6454a91334 | {'animation', 'kids'} | 2023-09-09 00:00:00.000000+0000 |   Jurassic Park


(4 rows)

cqlsh:aug_space> select * from movies_by_ratings where age_rating=9 order by title desc;

InvalidRequest: Error from server: code=2200 [Invalid query] message="Order by is currently only supported on the clustered columns of the PRIMARY KEY, got title"

No comments: