Cassandra IN query not working if table has SET type column

后端 未结 3 1408
别跟我提以往
别跟我提以往 2021-02-06 02:02

I am new to Cassandra. I got a issue in CQL IN query ,if table has SET type column it works.

CREATE TABLE test (
    test_date bigint, 
    test_id          


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-02-06 02:45

    You can use a Materialized View with test_id as a part of partitioning expression to satisfy your requirement if changing the PK on your base table is not an option:

    CREATE MATERIALIZED VIEW test1_mv AS
    SELECT * FROM test1
    WHERE test_date IS NOT NULL AND test_id IS NOT NULL
    PRIMARY KEY((test_date,test_id));
    

    Then use the Materialized View instead of the base table in your query:

    select * from test1_mv where test_date = 2022015 and test_id IN (1,2);
    

提交回复
热议问题