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

Add CQL cast functions for collections

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Triage Needed
    • Normal
    • Resolution: Unresolved
    • None
    • CQL/Semantics
    • None
    • All
    • None

    Description

      We have cast functions allowing to upcast numeric data types to bigger values. That is particularly useful for aggregation functions such as sum, that might overflow or loss precision if the return type has the same type as the aggregated values:

      CREATE TABLE t (k int PRIMARY KEY, v int);
      SELECT sum(cast(v AS varint)) FROM t;
      SELECT avg(cast(v AS float)) FROM t;
      

      CASSANDRA-18060 adds new CQL functions analogous to aggregate the elements of a collection, row per row. In order to be able to do the same type of casting, we should have the ability to cast collection values. For example:

      CREATE TABLE t (k int PRIMARY KEY, v list<int>);
      SELECT collection_sum(cast(v AS list<varint>)) FROM t;
      SELECT collection_avg(cast(v AS list<float>)) FROM t;
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              adelapena Andres de la Peña
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: