User-defined functions (UDFs) and user-defined aggregates (UDAs)

User-defined functions and aggregates examples used in the CQL documentation.

Requires setting the[enable_user_defined_functions] and[enable_scripted_user_defined_functions] to true in the cassandra.yaml file.


User-defined function.


Create a user-define function that trims row data from the left.


Create a user-define function that is an intermediate average state.


Create a user-define function that is a final average state.

Cycling user-defined aggregate team_average

Creates a Java user-defined aggregate function that calculates the average of a target column. Uses the average_state and average_final functions.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000,