[ 
https://issues.apache.org/jira/browse/CASSANDRA-18085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17643317#comment-17643317
 ] 

Andres de la Peña commented on CASSANDRA-18085:
-----------------------------------------------

Thanks for the review. I have tried to address the nits on the PR.

However I'm holding it a bit due to the after-review discussion on 
CASSANDRA-18060, where [~benedict] mentions the possibility of using the same 
{{{}max{}}}/{{{}min{}}}/{{{}sum{}}}/{{{}avg{}}} names for across-row aggregates 
and collection functions, depending on the column type. We also mentioned that 
option on CASSANDRA-17811 description, but we soon discarded it during the 
review.

That would clash with what we are proposing here, since there would and 
ambiguity when those functions are applied to single elements. That approach 
would base the function selection on the column type, so users requesting the 
min/max writetime/ttl of a column would require to know the type of the column 
to decide whether they use the collection function or not. Failing to do so 
would produce an unexpected collection or trigger an unexpected row 
aggregation. I personally think that using separate {{collection_*}} function 
names supporting singleton elements makes things clearer.

CC [~bereng]

> Add support for singletons on CQL collection functions
> ------------------------------------------------------
>
>                 Key: CASSANDRA-18085
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18085
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: CQL/Semantics
>            Reporter: Andres de la Peña
>            Assignee: Andres de la Peña
>            Priority: Normal
>             Fix For: 4.x
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> CASSANDRA-18060 has added generic CQL functions to get the min, max, sum, avg 
> and number of items in a collection. These functions can only be applied to 
> collection values. The functions throw an {{InvalidRequestEception}} when 
> applied to not-collection values.
> CASSANDRA-18078 has been pointed out that those functions could be applied 
> also to not-collection values, considering that the not-collection argument 
> can be considered a collection of a single element. For example:
>  * collection_min(7) = collection_min([7]) = collection_min(\{7}) = 7
>  * collection_max(7) = collection_max([7]) = collection_max(\{7}) = 7
>  * collection_sum(7) = collection_sum([7]) = collection_sum(\{7}) = 7
>  * collection_avg(7) = collection_avg([7]) = collection_avg(\{7}) = 7
>  * collection_count(7) = collection_count([7]) = collection_count(\{7}) = 1
> This would be particularly useful when used in combination with functions 
> such as {{writetime}} and {{{}ttl{}}}. Those functions can return either 
> single values or collections of values depending on whether the column passed 
> as argument is multicell. Thus, users interested on getting the 
> min/max/sum/avg of the writetimes/ttls of a column need to consider the type 
> of the column when choosing what functions they should use. With the proposed 
> change they could just use, for example, 
> {{collection_max(writetime(column))}} regardless of the column type.



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

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

Reply via email to