Faisal
Faisal

Reputation: 3

CQL : InvalidRequest: Error from server: code=2200 [Invalid query]

create table cd_ml_api.sf_leads (
    id timeuuid,
    email text ,
    cdh_org text,
    source_of_funds text ,
    currency_purpose text ,
    created_date timestamp,
    last_modified_date timestamp,
    PRIMARY KEY (email, last_modified_date)
)  WITH CLUSTERING ORDER BY (id DESC);

Showing error in cassandra terminal :

InvalidRequest: Error from server: code=2200 [Invalid query]
message="Missing CLUSTERING ORDER for column last_modified_date"

Upvotes: 0

Views: 1868

Answers (1)

undefined_variable
undefined_variable

Reputation: 6218

create table cd_ml_api.sf_leads (
    id timeuuid,
    email text ,
    cdh_org text,
    source_of_funds text ,
    currency_purpose text ,
    created_date timestamp,
    last_modified_date timestamp,
    PRIMARY KEY (email, last_modified_date)
)  WITH CLUSTERING ORDER BY (last_modified_date DESC);

Cassandra can sort by clustering key only. In order to sort by id it has to be part of clustering key.

Upvotes: 0

Related Questions