AMPS Function Overview

In the AMPS expression language, a function can be used in any place an identifier or literal value can be used.

All AMPS functions return a single value. During evaluation of an AMPS expression, AMPS calls the functions in the expression and uses the results to evaluate the expression. A function may perform type conversion as needed to evaluate the expression.

The results of a call to an AMPS function can be used as the parameter to an AMPS function. For example, the following is a valid expression:

REVERSE(SUBSTR('fandango',5)) == 'ogna'

In this case, AMPS first evaluates the SUBSTR function, which requests the subset of the string fandango, starting at position 5. That function returns ango. AMPS then uses the string ango as the input to the REVERSE function, which returns the result ogna.

The following table lists the available functions by category:

Deterministic and Non-Deterministic Functions

The AMPS server distinguishes between functions that produce a consistent value for the same message (deterministic functions) and functions that may produce a different value each time it is called, even if the function has the same input and is called for the update to the same message (non-deterministic functions).

There are no restrictions on the use of deterministic functions, since each time that they are called for a given message (or a given update to a message), they will return a consistent result.

Some features of AMPS rely on being able to evaluate an expression in a consistent way for a given message. A function that can produce a different value each time that it is called cannot be used in those situations: otherwise, AMPS could produce incorrect (or meaningless) results.

In practice, this means that a non-deterministic function:

  • Cannot be used in the filter of a subscription that requests out of focus (oof) notifications.

  • Cannot be used in the filter of an aggregated subscription (although a non-deterministic function is allowed in the filter of an aggregated query, since the filter will only be evaluated once per message).

  • Cannot be used in an aggregate function (aggregate functions are available in views, aggregated subscriptions, and aggregated queries).

  • Cannot be used in the filter for a sow_and_subscribe command that uses pagination (that is, a command that specifies top_n/skip_n/OrderBy).

  • Cannot be used in the filter for a queue or the barrier expression for a queue.

  • Cannot be used in the filter for a view or conflated topic.

  • Cannot be used in a replication filter.

In this release, LAST_READ, UNIX_TIMESTAMP and VALUE_LOOKUP are non-deterministic. The other functions provided with AMPS (both built in and provided through auxiliary modules) are deterministic.

Last updated

Copyright 2013-2024 60East Technologies, Inc.