As of version 3.0, Apache Cassandra allows users to create user-defined functions (UDFs). As CQL does not supply much in the way of extra tools and string utilities found in SQL, some of that function can be recreated with a UDF. Let's say that we want to query the current year from a date column. The date column will return the complete year, month, and day:
SELECT todate(now()) FROM system.local; system.todate(system.now())----------------------------- 2018-08-03(1 rows)
To just get the year back, we could handle that in the application code, or, after enabling user-defined functions in the cassandra.yaml file, we could write a small UDF using the Java language:
CREATE OR REPLACE FUNCTION year (input DATE) RETURNS ...