Guide to Expressions in AdapTableQL

Summary

  • AdapTableQL is an advanced, custom Query Language developed by the AdapTable Tools team
  • It evaluates and executes complex queries (called Expressions) defined at design or run time
  • AdapTableQL is designed and implemented to be fast, efficient and highly performant
  • It is also designed with the requirement to operate with large data sets in mind
  • Expressions are commonly used whenever data needs to be searched, filtered, watched, derived or evaluated
  • Expression can be hand-written or created in the Expression Editor - an advanced UI tool designed for this purpose
  • There are 3 main types of Expressions available in AdapTable:
    • Standard - Evaluates of each row in isolation
    • Aggregated - Evaluates data over a set of rows (with specialised Cumulative and Quantile aggregations)
    • Observable - A Reactive Expression used to watch data changes over time

AdapTableQL is a powerful, home-grown, Query Language designed by the AdapTable Tools team.

AdapTableQL includes a powerful rules engine used for evaluating live data.

Note

  • AdapTable also provides Predicates which are designed for more basic use cases
  • They are an entirely different way to query data in AdapTable than Expressions

Caution

  • You can use either Predicates or Expressions for any given use case, but they cannot be mixed together
  • e.g. you cannot include a Custom Predicate in an Expression, or reference an Expression Function in a Predicate

Expressions

At the heart of AdapTableQL are Expressions - a very powerful querying construct which:

  • Can contain numerous functions, conditions and arguments
  • Are typically evaluated against whole rows of AG Grid data
  • Can support multiple return types
  • Includes reactive(observable), aggregated or cumulated expressions
  • Are designed to be fully human-readable and can be written entirely by hand

Hint

  • Expressions required for Initial Adaptable State can be entirely handwritten if that is the preference
    • Alternatively, they can be first created in the UI and then the contents copied over into the Initial State file

There are 3 main types of Expressions provided by AdapTableQL:

TypeReturnsModules
StandardSingle value of any typeAlerts (Boolean)
Calculated Column (Any)
Export (Boolean)
Flashing Cell (Boolean)
Format Column (Boolean)
Grid Filter (Boolean)
Plus Minus (Boolean)
AggregationSingle value (calculated across aggregated cells) - also includes specialist Cumulative and Quantile AggregationsAlerts (Boolean)
Calculated Column (Any, Quantile, Cumulative)
ObservableDetails of any Row or Grid ChangesAlerts

Standard

A Standard Expression is evaluated against each row in isolation and returns a single value.

Note

Standard (particularly Boolean) Expressions are the most common type of Expression used in AdapTable

The return value can be of 2 return types:

  • any data type - used in the Calculated Column Module
  • boolean data type - used when a true / false condition needs to be evaluated, e.g. Grid Filter Module only displays rows, and Conditional Styling only styles rows, where the evaluated Expression returns true.

Find Out More

Aggregated

Aggregated Expressions are run against aggregated data; each value is dynamically derived by aggregating multiple rows and columns of the grid. There are 4 types of Aggregated Expression :

  • Aggregated Scalar - return value of any data type and available when creating Calculated Columns.
  • Aggregated Boolean Expressions: return true / false currently used in the Alerts Module.

Hint

  • This is ideal for Limits Management and related scenarios
  • You can check that a sum comprising multiple cell values has not been exceeded
  • Cumulative Expressions - Perform Cumulative Aggregations

  • Quantile Expressions - Create 'buckets' of values

Find Out More

Observable (Rx)

Observable Expressions use advanced reactive techniques (Rx) to watch for changes (or lack of changes) in data that match a particular pattern.

When the expression evaluates to TRUE, AdapTable can perform a specified action.

Note

Currently only Alerts supports Observable Expressions, but this will be extended to other Modules

Find Out More

Expression Modules

AdapTable users are able to use Expressions in numerous Modules.

Note

Some Adaptable Module may reference more than one type of Expression

ModuleTypeUsage
AlertsStandardTriggers an Alert when data change matches a Rule
AlertsObservableTriggers an Alert based on observed criteria
AlertsAggregatedTriggers an Alert using aggregation functions
Calculated ColumnStandardExpression is evaluated for each cell in the column
Calculated ColumnAggregatedExpression is evaluated by aggregating multiple grid cells
Calculated ColumnCumulativePerforms Cumulative Aggregations
Calculated ColumnQuantileCreates 'buckets' of values
ExportStandardCustom Reports only exports rows returned by Query
Flashing CellStandardWhether the Cell should flash when its value changes
Format ColumnStandardSets whether or not to show the Format Column
Grid FilterStandardReturns rows which match the true / false condition
Plus MinusStandardManages evaluation of Custom Nudge Values

Expression Functions

An Expression will include (potentially multiple) Expression Functions.

These are useful functions that are shipped with AdapTableQL which cover a multitude of use cases.

Hint

Developers are able to provide Custom Expression Functions if required

There are 3 types of Expression function available in AdapTableQl - in line with the 3 types of Expressions:

TypeDescriptionAvailable in Expressions
StandardReturns single value of any return typeStandard, Observable, Aggregation
ObservableWatches for ChangesObservable
AggregationReturns single value of any return typeAggregation

For example this Standard Expression contains 3 Expression Functions:

 STARTS_WITH([col1], 'ABC') OR MIN([col2], [col3]) > 100
  • STARTS_WITH Boolean Expression Function
  • OR Logical Function
  • MIN Scalar Expression Function

Find Out More

Consult the AdapTableQL Expression List for full details of all the Expression Functions available in AdapTableQL

Advanced Expression Functions

AdapTableQL provides some "specialised" Functions for particular, advanced use cases:

  • QUERY Function - enables referencing Named Queries in other Expressions

Note

A Named Query is a Boolean Expression that has been named and saved into Query State for subsequent re-use

  • VAR Function - allows developers to provide values which will be evaluated in other Expressions
  • CASE and Ternary Operators - enable logic to be used inside Expressions

Find Out More

See Advanced Expressions for full details on all of these functions

Writing Expressions

Expressions are designed to be hand-written and human readable. An Expression can include many different elements including:

  • Expression Functions
  • Operators
  • Columns
  • Hard coded values

Note

Expression can contain as many of each of these elements as are required

Find Out More

See Standard Expressions for in-depth instructions on creating Expressions

UI Components

AdapTableQL is designed to be used at run time by end users with no technical expertise.

AdapTable provides 2 very useful UI Components designed to add easy creation of Expressions:

  • Query Builder enables (Boolean) Expressions to be created purely via UI controls

  • Expression Editor used to hand-write Expressions (and for more complicated scenarios), and contains many useful features including functions list, context help and validation

Find Out More

See Standard Expressions for more information

Configuring Expressions

Many elements in AdapTableQL can be configured using properties in Expression Options.

In particular developers are able to:

  • add Custom Expression Functions
  • ensure that some Expression Functions are unavailable (both to end-users or to AdapTableQL)
  • reduce complexity - useful when evaluating expressions externally
  • configure case sensitivity

Custom AdapTableQL Functions

Developers can provide their own custom built ExpressionFunctions in Expression Options.

Once provided, these Expressions will be available in the Expression Editor and invoked by AdapTableQL when the Expression is being evaluated.

Find Out More

Reducing Expression Complexity

By default, all System Expression Functions are available to end users, and can be used against all columns.

However sometimes developers might wish to reduce the AdapTableQL functionality on offer.

Note

This is often the case if you are evaluating Expressions yourself externally instead of using AdapTableQL

In this scenario, AdapTable provides 2 features to help developers - namely:

Find Out More

See Reducing Expression Complexity for further information

Evaluating Expressions Externally

Generally there is no need for developers to understand how AdapTableQL works; merely to ensure that it is provided with valid input.

However, occasionally you might want to perform some querying externally (e.g. on your Server).

Note

This is possible and requires 3 steps:

  1. In Expression Options specify which modules should be evaluated externally (instead of AdapTableQL)
  2. Listen to the Grid Filter Applied Event to know when Queries need to run
  3. Perform the Query yourself and return the data to Adaptable

Hint

  • To help with this scenario, AdapTable makes available the AST which AdapTableQL uses for the Expression
  • This Abstract Syntax Tree can be accessed via functions in Expression API

Find Out More

The Server Evaluation Guide provides full details on external Expression evaluation

Case Sensitivity

By default Expressions are case insensitive but this can be changed if required, by setting the caseSensitiveExpressions flag to true.

caseSensitiveExpressions

Default: false
Boolean
Keep case sensitivity when AdapTableQL evaluates string-based Expressions

FAQ

Why are there no Round or Trunc functions as these are very useful AdapTable tries to keep the functions pure so they return the full value

Hint

You can use Column Formatting to trunc or round numeric figures for display purposes