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

Consider removing MAXWRITETIME function

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • 5.0.x
    • CQL/Syntax
    • None
    • Semantic
    • Low Hanging Fruit
    • All
    • None
    • Hide

      The tests for maxwritetime are updated to use collection_max(writetime) instead

      Show
      The tests for  maxwritetime are updated to use collection_max(writetime) instead

    Description

      CASSANDRA-17425 added a new MAXWRITETIME function that allows to retrieve the maximum timestamp of a multi-cell column. For example:

      > CREATE TABLE t (k int PRIMARY KEY, v set<int>);
      > INSERT INTO t (k, v) VALUES (1, {1, 2}) USING TIMESTAMP 100;
      > UPDATE t USING TIMESTAMP 200 SET v += {3} WHERE k=1;
      > SELECT maxwritetime(v) FROM t;
      
       maxwritetime(v)
      -----------------
                   200
      

      Later, CASSANDRA-8877 added the means to retrieve the write times and TTLs of each of the cells in a multi-cell column:

      > SELECT writetime(v) FROM t;
      
       writetime(v)
      -----------------
       [100, 100, 200]
      
      > SELECT writetime(v[1]) FROM t;
      
       writetime(v[1])
      -----------------
                   100
      

      Quite recently, CASSANDRA-18060 has added generic CQL functions to get the min and max items in a collection. Those functions can be used in combination with the classic writetime function to get the same results as the new maxwritetime function:

      > SELECT collection_max(writetime(v)) FROM t;
      
       system.collection_max(writetime(v))
      -------------------------------------
                                       200
      

      Those new functions can also be used to get the min timestamp, or the min/max TTL, for which there isn't a specific function:

      SELECT collection_min(writetime(v)) FROM t;
      SELECT collection_max(writetime(v)) FROM t;
      SELECT collection_avg(writetime(v)) FROM t;
      SELECT collection_min(ttl(v)) FROM t;
      SELECT collection_max(ttl(v)) FROM t;
      SELECT collection_avg(ttl(v)) FROM t;
      

      I think this makes the new maxwritetime mostly redundant, since the new functions can achieve the same results in a more generic way. Since the new maxwritetime function is only on trunk, we should consider whether we want to remove it in favour of the generic functions.

      Attachments

        Issue Links

          Activity

            People

              smiklosovic Stefan Miklosovic
              adelapena Andres de la Peña
              Stefan Miklosovic
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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