spring-projects / spring-data-cassandra

Provides support to increase developer productivity in Java when using Apache Cassandra. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-cassandra/
Apache License 2.0
380 stars 311 forks source link

how can i use group by #1324

Closed a11enhuang closed 1 year ago

a11enhuang commented 1 year ago

Here is querying data from data is done using a SELECT statement from cassandra:

select_statement::= SELECT [ JSON | DISTINCT ] ( select_clause | '*' )
    FROM `table_name`
    [ WHERE `where_clause` ]
    [ GROUP BY `group_by_clause` ]
    [ ORDER BY `ordering_clause` ]
    [ PER PARTITION LIMIT (`integer` | `bind_marker`) ]
    [ LIMIT (`integer` | `bind_marker`) ]
    [ ALLOW FILTERING ]
select_clause::= `selector` [ AS `identifier` ] ( ',' `selector` [ AS `identifier` ] )
selector::== `column_name`
    | `term`
    | CAST '(' `selector` AS `cql_type` ')'
    | `function_name` '(' [ `selector` ( ',' `selector` )_ ] ')'
    | COUNT '(' '_' ')'
where_clause::= `relation` ( AND `relation` )*
relation::= column_name operator term
    '(' column_name ( ',' column_name )* ')' operator tuple_literal
    TOKEN '(' column_name# ( ',' column_name )* ')' operator term
operator::= '=' | '<' | '>' | '<=' | '>=' | '!=' | IN | CONTAINS | CONTAINS KEY
group_by_clause::= column_name ( ',' column_name )*
ordering_clause::= column_name [ ASC | DESC ] ( ',' column_name [ ASC | DESC ] )*

From the description it supports the group by operator. But I can't use it in spring-data-cassandra.Couldn't find the corresponding description in the documentation either. how can i use this go

mp911de commented 1 year ago

Spring Data Cassandra accepts CQL as string, so you provide the CQL query as-is.

Please note that we do not support grouping through the entity template API as we work with individual entity instances or lists but not aggregations.