[ 
https://issues.apache.org/jira/browse/CASSANDRA-18074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andres de la Peña updated CASSANDRA-18074:
------------------------------------------
    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:
{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 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:
{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}

  was:
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}


> 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
>            Priority: Normal
>
> 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 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:
> {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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to