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

Add a "history" command to cqlsh. Perhaps "show history"?

    XMLWordPrintableJSON

Details

    • Low Hanging Fruit
    • Hide

      Original Patch PR: https://github.com/apache/cassandra/pull/1866/files

       [NEW - NEEDS REVIEW] 09/22/22: documentation patch https://github.com/apache/cassandra/commit/31f9a566bb70368dbffddeb672196355efe7ebb0 

      Unit tests to be implemented:
      1. check "history" command outputs correct length of results

      2. check "history" command outputs correct contents & order

       

      The current patch implements the feature in its minimally viable form. Here's some of my ideas for improvement to current patch:

      1. allow an input argument to control how many commands will be listed.
      2. showing the timestamp of when each command is executed.
      3. showing whether each command is valid/successfully executed, OR, showing only the successfully executed commands.

      ----------------------------

      19 May 2023 New Patch 

      https://github.com/apache/cassandra/pull/2354

      This patch is an update of the original PR create by Yundi Chen. It slightly revises the HISTORY command syntax by adding a optional argument for the number of lines to display. 

      A few implementation notes:

      • The parser ensures that the value of <n> is a <wholenumber>, i.e., a non-negative integer.  I tried creating a <positiveinteger> type, but that caused numerous issues with unit tests.  This is implemented similar to 'paging', which specifies <wholenumber> also. Zero and less than 10 might not be practical values, but the parsing framework isn't setup to restrict them at the moment.  Also, Bash 'history' accepts '1' as an arg, so there are related implementations which don't restrict the range of integer values.
      • The number of rows to display is a session setting not a permanent one.  Typically, a user has a known range of history you wish to look through, such as recent queries, or much older queries (larger value of n).  You might want to see the last 10 lines for something you just ran a few minutes ago, or 1000 lines for something you ran last week. 
      Show
      Original Patch PR: https://github.com/apache/cassandra/pull/1866/files   [NEW - NEEDS REVIEW] 09/22/22: documentation patch https://github.com/apache/cassandra/commit/31f9a566bb70368dbffddeb672196355efe7ebb0   Unit tests to be implemented: 1. check "history" command outputs correct length of results 2. check "history" command outputs correct contents & order   The current patch implements the feature in its minimally viable form. Here's some of my ideas for improvement to current patch: allow an input argument to control how many commands will be listed. showing the timestamp of when each command is executed. showing whether each command is valid/successfully executed, OR, showing only the successfully executed commands. ---------------------------- 19 May 2023 New Patch  https://github.com/apache/cassandra/pull/2354 This patch is an update of the original PR create by Yundi Chen. It slightly revises the HISTORY command syntax by adding a optional argument for the number of lines to display.  A few implementation notes: The parser ensures that the value of <n> is a <wholenumber>, i.e., a non-negative integer.  I tried creating a <positiveinteger> type, but that caused numerous issues with unit tests.  This is implemented similar to 'paging', which specifies <wholenumber> also. Zero and less than 10 might not be practical values, but the parsing framework isn't setup to restrict them at the moment.  Also, Bash 'history' accepts '1' as an arg, so there are related implementations which don't restrict the range of integer values. The number of rows to display is a session setting not a permanent one.  Typically, a user has a known range of history you wish to look through, such as recent queries, or much older queries (larger value of n).  You might want to see the last 10 lines for something you just ran a few minutes ago, or 1000 lines for something you ran last week. 

    Description

      I was trying to capture some create key space and create table commands from a running cqlsh, and found there was no equivalent to the '\s' history command in Postgres' psql shell.  It's a great tool for figuring out what you were doing yesterday.

      Attachments

        Issue Links

          Activity

            People

              bschoeni Brad Schoening
              cosowes Wes Peters
              Brad Schoening, Yundi Chen
              Brandon Williams, Stefan Miklosovic
              Votes:
              0 Vote for this issue
              Watchers:
              7 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 10m
                  1h 10m