Use Plain Functions to Update, Select or Sort Rows
You can apply plain functions to individual columns in a dataset stream in any clause in a RAQL query. Plain functions can update data in each row in the Select clause, help to filter rows in Where conditions or help to sort results in Order By. They can also be used along with analytic functions in Over or Group By clauses or in subqueries in From clauses.
MashZone NextGen includes a set of built-in plain functions. See
Built-In
RAQL
Functions for details. You may also have additional plain, user-defined functions available.
The first example uses the built-in plain function split_part in the Select clause, to split longitude and latitude data into two columns for the Manufacturing Plants dataset.
The Select clause uses the split_part function on the Location column to split the data into two separate pieces before and after a comma delimiter. The first call extracts the latitude and the second call extracts the longitude. In each case the result of the function is added to the query results as a separate column using as alias to provide the name of the new column.
The next example uses the cast function in a Where clause to ensure that the Active_Production_Lines column is treated as a number for filtering. Casting functions simply cast the data in the column to an appropriate datatype.
The last example uses the sample dataset for US legislators previously introduced in
A Basic
RAQL
Query. It sorts legislators by state and district, using the
cast function to ensure that their district is sorted numerically: