Apache Cassandra

Cassandra Show User-Defined Functions, Aggregates and User Types

“In this short tutorial, we will discuss how you can view all the user-defined functions, aggregates and user types in your server.”

Let us explore.

Keep in mind that we do not cover the process of creating User-Defined Functions, Aggregates or user types in this tutorial. If you wish to learn more about that, check out our tutorials on the topics to learn more.

Cassandra Fetch User-Defined Functions

To show all the User-Defined Functions in Cassandra, fetch all the records in the system_schema.functions table as shown:

cassandra@cqlsh:zero_day> select * from system_schema.functions;

This should return the details about the function definitions as shown in the example below:

@ Row 1
----------------------+-------------------------------------------------------------------
keyspace_name        | zero_day
function_name        | log_func
argument_types       | ['double']
argument_names       | ['input']
body                 |       return Double.valueOf(Math.log(input.doubleValue()));
called_on_null_input | True
language             | java
return_type          | double

In this case, we have one function only.

Cassandra Show User Types

Similarly, to fetch user types, we can query the types table as shown in the example below:

cassandra@cqlsh:zero_day> select * from system_schema.types;

The resulting output is as shown:

@ Row 1
---------------+-----------------------------------
keyspace_name | zero_day
type_name     | user_info
field_names   | ['id', 'country', 'age', 'email']
field_types   | ['int', 'text', 'int', 'text']
(1 rows)

In this case, we have one user type with the details shown above.

Cassandra Show User-Defined Aggregates

To show the user-defined aggregates, query the aggregates table as shown:

select * from system_schema.aggregates;

If you have any defined aggregates, you should see them from this table.

Termination

The system_schema table holds useful information stored in the cluster, such as UDF, views, data types, keyspaces, etc.

Thanks for reading!!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list