Creating user-defined function (UDF)
User-Defined Functions (UDFs) can be used to manipulate stored data with a function of the user's choice.
Allows users to define functions that can be applied to data stored in a table as
part of a query result. The function must be created prior to its use in a SELECT
statement. The function will be performed on each row of the table. To use
user-defined functions with Java or Javascript,
enable_user_defined_functions
must be set true
in the cassandra.yaml file setting to enable the functions.
User-defined functions are defined within a keyspace; if no keyspace is defined, the
current keyspace is used. User-defined functions are executed in a sandbox
By default, Cassandra supports defining functions in java
and
javascript
. Other scripting languages, such as
Python
, Ruby
, and Scala
can
be added by adding a JAR to the classpath. Install the JAR file into
$CASSANDRA_HOME/lib/jsr223/[language]/[jar-name].jar where
language is 'jruby', 'jython', or 'scala'