You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Andres de la Peña (Jira)" <ji...@apache.org> on 2022/11/25 12:21:00 UTC

[jira] [Created] (CASSANDRA-18074) Add CQL cast functions for collections

Andres de la Peña created CASSANDRA-18074:
---------------------------------------------

             Summary: Add CQL cast functions for collections
                 Key: CASSANDRA-18074
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18074
             Project: Cassandra
          Issue Type: New Feature
          Components: CQL/Semantics
            Reporter: Andres de la Peña


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:
{code:java}
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;
{code}
CASSANDRA-18060 will add 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:
{code:java}
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;
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org