About SRL functions

The function is the main element of the SRL.

Functions are used to make SRL perform a complex process. Functions might consist of finding the square root of a number, the first 5 characters of a string, or finding the difference in seconds between two points in time. Users give functions values, and get a value in return.

Syntax:

function_name(argument_1, argument_2, etc.)

Every SRL function has a return value that will be one of the SRL data types. Arguments can consist of any data type, a column name, a primitive value, or another nested function.

For example, consider the simple function called sqrt() which returns a square root of a number.

Suppose we want the square root of the value 4. To do this we type sqrt(4). The result would be 2.

Note that some functions work with several arguments, or incoming values (for example, the pow() function).

There are many different types of functions, which are usually organized by their purpose or the type of value they output, or the types of values they use as input. The following sections list the available types of functions, with descriptions and examples of how each function is used.

Functions can be nested within each other.

The sqrt(sqrt(16)) query will return 2.

First, the nested square root function is executed, which is 4. Then the outer function is executed, where the result of the square root of 4 is 2.

References for SRL functions

All the SRL functions are described in detail in a separate section.

You can also get a quick reference on on the SRL functions in the node settings by clicking on the corresponding button.

srl funct ref

You can also get information on a specific SRL function by hovering the mouse cursor over the name of the function that you added to the text field.

srl ref example

Click on the "eye" icon in the pop-up hint window to open the specified function description

srl specific example

Click on the "eye" icon in the pop-up hint window holding the CTRL button to open the specified function description in a new browser tab.

A warning about using date functions

Functions involving date values require an actual value stored using the date data type. However, some of the examples shown below use dates presented as strings. This is merely for clarity.

For example, the day() function may use of an example of day("a string that looks like a date").

The string within PolyAnalyst would have to be an actual date, which could be a Date/time column, or a value created by using the makedate() function.

Notes on using null with functions

SRL provides several functions for working with null values. The term null represents the concept of emptiness, or missing. Notably, a null value is not equivalent to a string value with zero characters present, as even an empty string is still a value that is "present and not empty". A null value is also the easiest type of value to store in PolyAnalyst, because it occupies almost no disk space.

Working with null values in SRL and PDL can cause unexpected results in certain situations. You should always consider how your SRL expression will behave in the presence of null data values.

More on the null values see above.