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

Better display table organization on desc table via primary key list

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Fix Version/s: 2.0.9
    • Component/s: None
    • Labels:
      None

      Description

      In cqlsh, the desc table command does not make it sufficiently clear which columns are part of the row key and which are clustering keys.

      A simple change to the primary key list, though, would make it easier to tell.

      Consider the following table definition:

      create table my_table {
        first_column text,
        second_column text,
        third_column text,
        primary key (first_column, second_column, third_column)
      }
      

      This table has a row key of first_column and clustering keys of second_column, third_column. But if the user intended for the table to have all three in the row key, the correct definition would be:

      create table my_table {
        first_column text,
        second_column text,
        third_column text,
        primary key ((first_column, second_column, third_column))
      }
      

      But this is a sufficiently subtle difference that the first may be mistaken for the second or vice-versa.

      My suggested solution is to always wrap the row key in parentheses. This is already supported by create table syntax, so it's just a matter of changing desc table to display the create table statement with the primary key always in parentheses, like so:

      create table my_table {
        first_column text,
        second_column text,
        third_column text,
        primary key ((first_column), second_column, third_column)
      }
      
      1. 7274.txt
        0.5 kB
        Patrick McFadin
      2. 7274-2.txt
        0.7 kB
        Patrick McFadin

        Activity

        Hide
        iamaleksey Aleksey Yeschenko added a comment -

        Committed, thanks.

        Show
        iamaleksey Aleksey Yeschenko added a comment - Committed, thanks.
        Hide
        pmcfadin Patrick McFadin added a comment -

        You are right. Much simpler. Attaching updated patch.

        Show
        pmcfadin Patrick McFadin added a comment - You are right. Much simpler. Attaching updated patch.
        Hide
        iamaleksey Aleksey Yeschenko added a comment -

        Patrick McFadin you should just get rid of the if len(..) statement there and make the first branch unconditional

        Show
        iamaleksey Aleksey Yeschenko added a comment - Patrick McFadin you should just get rid of the if len(..) statement there and make the first branch unconditional
        Hide
        pmcfadin Patrick McFadin added a comment -

        This is just against 2.0.x As I understand it, 2.1 now uses the DataStax Python driver for format. I'll have to do a patch for that separately.

        Show
        pmcfadin Patrick McFadin added a comment - This is just against 2.0.x As I understand it, 2.1 now uses the DataStax Python driver for format. I'll have to do a patch for that separately.
        Hide
        pmcfadin Patrick McFadin added a comment -

        Simple change in cqlsh to add parenthesis around a single partition key when doing a "DESCRIBE TABLE"

        Show
        pmcfadin Patrick McFadin added a comment - Simple change in cqlsh to add parenthesis around a single partition key when doing a "DESCRIBE TABLE"
        Hide
        iamaleksey Aleksey Yeschenko added a comment -

        Wouldn't this create a composite partition key of size 1?

        It wouldn't, so not against it on principle.

        Show
        iamaleksey Aleksey Yeschenko added a comment - Wouldn't this create a composite partition key of size 1? It wouldn't, so not against it on principle.
        Hide
        iamaleksey Aleksey Yeschenko added a comment -

        Wouldn't this create a composite partition key of size 1?

        Show
        iamaleksey Aleksey Yeschenko added a comment - Wouldn't this create a composite partition key of size 1?
        Hide
        mishail Mikhail Stepura added a comment -

        +1 for explicit indication of a partition key.

        Show
        mishail Mikhail Stepura added a comment - +1 for explicit indication of a partition key.
        Hide
        pmcfadin Patrick McFadin added a comment -

        I like it for clarity. The possible alternative than default behavior would be to flag some sort of verbose mode.

        Show
        pmcfadin Patrick McFadin added a comment - I like it for clarity. The possible alternative than default behavior would be to flag some sort of verbose mode.
        Hide
        brandon.williams Brandon Williams added a comment -

        I don't have any strong feelings either, except in the case of replaying schema, I don't want a regression there.

        Show
        brandon.williams Brandon Williams added a comment - I don't have any strong feelings either, except in the case of replaying schema, I don't want a regression there.
        Hide
        jbellis Jonathan Ellis added a comment -

        I have no strong feelings here. WDYT Tyler Hobbs Brandon Williams Mikhail Stepura?

        Show
        jbellis Jonathan Ellis added a comment - I have no strong feelings here. WDYT Tyler Hobbs Brandon Williams Mikhail Stepura ?

          People

          • Assignee:
            pmcfadin Patrick McFadin
            Reporter:
            gworley3 G Gordon Worley III
            Reviewer:
            Aleksey Yeschenko
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development