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

Inconsistent "position" numbering for keys in "system_schema.columns"

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Fixed
    • Fix Version/s: 3.0.0
    • Component/s: None
    • Severity:
      Low

      Description

      A single component partition key starts off with a -1 position.

      cqlsh> CREATE TABLE test.table1 (key1 text, value1 text, value2 text, PRIMARY KEY(key1));
      cqlsh> SELECT keyspace_name, table_name, column_name, kind, position FROM system_schema.columns WHERE keyspace_name = 'test' and  table_name = 'table1' ;
      
       keyspace_name | table_name | column_name | kind          | position
      ---------------+------------+-------------+---------------+----------
                test |     table1 |        key1 | partition_key |       -1
                test |     table1 |      value1 |       regular |       -1
                test |     table1 |      value2 |       regular |       -1
      

      A single component clustering key starts off with a 0 position.

      cqlsh> CREATE TABLE test.table2 (key1 text, value1 text, value2 text, PRIMARY KEY(key1, value1));
      cqlsh> SELECT keyspace_name, table_name, column_name, kind, position FROM system_schema.columns WHERE keyspace_name = 'test' and  table_name = 'table2' ;
      
       keyspace_name | table_name | column_name | kind          | position
      ---------------+------------+-------------+---------------+----------
                test |     table2 |        key1 | partition_key |       -1
                test |     table2 |      value1 |    clustering |        0
                test |     table2 |      value2 |       regular |       -1
      

      When another component is added to the partition key it starts at 0.

      cqlsh> CREATE TABLE test.table3 (key1 text, value1 text, value2 text, PRIMARY KEY((key1, value1)));
      cqlsh> SELECT keyspace_name, table_name, column_name, kind, position FROM system_schema.columns WHERE keyspace_name = 'test' and  table_name = 'table3' ;
      
       keyspace_name | table_name | column_name | kind          | position
      ---------------+------------+-------------+---------------+----------
                test |     table3 |        key1 | partition_key |        0
                test |     table3 |      value1 | partition_key |        1
                test |     table3 |      value2 |       regular |       -1
      

      which is the same as a multiple component clustering key.

      cqlsh> CREATE TABLE test.table4 (key1 text, value1 text, value2 text, PRIMARY KEY(key1, value1, value2));
      cqlsh> SELECT keyspace_name, table_name, column_name, kind, position FROM system_schema.columns WHERE keyspace_name = 'test' and  table_name = 'table4' ;
      
       keyspace_name | table_name | column_name | kind          | position
      ---------------+------------+-------------+---------------+----------
                test |     table4 |        key1 | partition_key |       -1
                test |     table4 |      value1 |    clustering |        0
                test |     table4 |      value2 |    clustering |        1
      

      Shouldn't a single component partition key start off with a position of 0?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                slebresne Sylvain Lebresne
                Reporter:
                mpenick Michael Penick
                Authors:
                Sylvain Lebresne
                Reviewers:
                Sam Tunnicliffe
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: