Cassandra API - unable to run query

Jayarami Annapureddy 0 Reputation points
2023-02-16T20:00:04.4533333+00:00

More details about problem,

Cassandra API of Azure Cosmos DB,

ERROR: com.datastax.driver.core.exceptions.InvalidQueryException:

ORDER BY requires creating a custom index: CosmosClusteringIndex.

Please create a custom index and re-issue this query

Query = select * from jaeger_v1_sbox.service_name_index where

service_name = 'traces-generate-demo' order by start_time allow

filtering ;

Table script:

CREATE TABLE IF NOT EXISTS jaeger_v1_sbox.service_name_index (
    service_name      text,
    bucket            int,
    start_time        bigint,
    trace_id          blob,
    PRIMARY KEY ((service_name, bucket), start_time)
) WITH CLUSTERING ORDER BY (start_time DESC)
    AND compaction = {
        'compaction_window_size': '1',
        'compaction_window_unit': 'HOURS',
        'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'
    }
    AND default_time_to_live = 172800
    AND speculative_retry = 'NONE'
    AND gc_grace_seconds = 10800;

-- WORKING --
select * from jaeger_v1_sbox.service_name_index where service_name = 'traces-generate-demo' allow filtering;
select * from jaeger_v1_sbox.service_name_index order by start_time desc;


-- NOT WORKING ---
select * from jaeger_v1_sbox.service_name_index where service_name = 'traces-generate-demo' 
order by start_time allow filtering ;

Image:cassandra-error

I tried to create custom index but got error but I am querying on clustering column and it is not working only when filtering is applied. Could you please help how to resolve this ?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,901 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2023-02-17T15:07:48.2866667+00:00

    Hi, @Jayarami Annapureddy Welcome to the Microsoft Q&A forum, Thanks for posting your question.

    You need to create an index – however, the Index for clustering columns is still in preview for Cassandra API.please refer to this Blog here - Now in private preview: Cluster Key Index support for Azure Cosmos DB Cassandra API - Azure Cosmos DB Blog (microsoft.com)

     

    Please let us know if you are looking for more details on how to enable it.

    Regards

    Geetha


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.