Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-19889

Indexing a frozen collection that is the clustering key and reversed is rejected

    XMLWordPrintableJSON

Details

    Description

      CREATE TABLE tbl (
        pk int,
        ck frozen<list<int>>,
        value int,
        PRIMARY KEY(pk, ck)
      )
      WITH CLUSTERING ORDER BY (ck DESC)
      

      If you index “ck” it will fail

      CREATE INDEX ON tbl(FULL(ck));
      

      The failure error is

      Caused by: org.apache.cassandra.exceptions.InvalidRequestException: full() indexes can only be created on frozen collections
      	at org.apache.cassandra.cql3.statements.schema.AlterSchemaStatement.ire(AlterSchemaStatement.java:222)
      	at org.apache.cassandra.cql3.statements.schema.CreateIndexStatement.validateIndexTarget(CreateIndexStatement.java:250)
      	at org.apache.cassandra.cql3.statements.schema.CreateIndexStatement.lambda$apply$1(CreateIndexStatement.java:177)
      

      The reason? We have a ReverseType column! We must “unwrap” the type before this check...

      Basic test

      schemaChange(format("CREATE TABLE %s.tbl (\n" +
                                  "  pk int,\n" +
                                  "  ck frozen<list<int>>,\n" +
                                  "  value int,\n" +
                                  "  PRIMARY KEY(pk, ck)\n" +
                                  ")\n" +
                                  "WITH CLUSTERING ORDER BY (ck DESC)", KEYSPACE));
      schemaChange(format("CREATE INDEX ON %s.tbl(FULL(ck));", KEYSPACE));
      

      Attachments

        Issue Links

          Activity

            People

              Novice_P Sunil Ramchandra Pawar
              dcapwell David Capwell
              Sunil Ramchandra Pawar
              David Capwell, Stefan Miklosovic
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h