Decision Table Syntax for Building Rules


This topic explains the business rules syntax used to build Decision Table artifacts in TIBCO Streaming Model Management Server (MMS).


Overview

The MMS client provides the Artifact Editor to build rules, where you define threshold value conditions and actions in the cells of a table. In MMS, these tables are referred to as Decision Table artifacts, which are similar to TIBCO StreamBase® Decision Tables.

Each row can be thought of as a single rule in a Decision Table. The individual rules are often straightforward, as shown in the examples below. Artifacts stored in the MMS repository can be deployed to a TIBCO StreamBase EventFlow™ module whose configuration includes a StreamBase Decision Table operator.

The TIBCO StreamBase® Add-in for Microsoft Excel is a supported decision table editor. Microsoft Excel Add-in releases 2.7.0 and above also support upload and download artifacts to and from MMS. The Excel Add-in is a separately installed product and its documentation can be found here.


Conditions and Actions in Decision Tables

A Decision Table consists of columns where each column represents one condition or one action.

A condition is a predicate test that must be evaluated to true for the associated action to be executed. If a Decision Table rule uses multiple conditions, all conditions for a row must be evaluated to true for the action(s) to be executed. Condition tests might be looking to match the exact value of an incoming field's value, or might be comparing an incoming value for whether it is greater than, less than, greater than or equal to, or less than or equal to a specified value.

An action is an operation that is executed when the appropriate conditions are met.

In each rule's row, you define the specific conditions and actions that comprise that rule. For example, if a condition column is Age (comparing to an incoming tuple field of that name), then each row can define a different age range. The action for each row would define what action to take if an incoming tuple contains an Age value within the specified range.

If you add a second condition column called Name, then before the action is taken, the running StreamBase Decision Table operator tests both conditions to check whether both the incoming Age and Name field values are within the range as specified in the rules.

For more information, see TIBCO Streaming.

The features of Condition columns are as given below:

  • A column is not necessarily associated with a specific field in the incoming tuple.

  • The cell content comprises of full StreamBase expressions that resolve to a boolean value.

  • The cell content can reference other fields in the incoming tuple.

  • String literals must be enclosed in double quotes.

The features of Action columns are as given below:

  • A column is associated with a specific field in the outgoing action tuple.

  • The cell content comprises of full StreamBase expressions that must evaluate to the type of the corresponding action tuple field.

  • The cell content can reference incoming tuple fields.

  • String literals must be enclosed in double quotes.


Condition and Action Cell Syntax

The syntax for a Decision Table cell content depends on the type of column of the cell as explained below.

Condition Columns:

Cells within the Condition columns can contain arbitrary StreamBase expressions that evaluate to boolean values. Expressions can reference one or more fields in the Decision Table operator's input schema. The expressions have the following limitations:

  • No references to dynamic variables.

  • No references to constants defined in .sbapp and .sbint files.

  • Simple expression language functions only (no aggregate functions).

The valid logical operators include:

Type Operator
Logical AND &&
Logical OR ||

The valid relational operators include:

Type Example Details
Less than <  
Less than or equal <=  
Greater than >  
Greater than or equal >=  
Equal == This operator is implied when no operator is present.
Not equal !=  

Some valid sample StreamBase expressions are given below:

  • Name == "Peter"
  • length(Name) > 10
  • Age >= 18 && Age <= 21
  • length(MyListOfDouble) > 0 && MyListOfDouble [0] == 3.14159
  • MyTuple.MyBool
  • MyTuple.MyInt == 5
  • MyTuple.MyString == "Paul" && Age > 21
  • length(MyTuple.MyListOfString) > 2 && MyTuple.MyListOfString[2] == "Mary"
  • MyTuple.MyTimestamp > '2016-06-03 10:00:00.000-0400'
  • Age == 17 && Name == "Peter" && MyTuple.MyString == "Paul" && length(MyTuple.MyListOfString) > 2 && MyTuple.MyListOfString[2] == "Mary"

Action Columns:

Cells within Action columns can contain arbitrary StreamBase expressions that evaluate to the data type of the corresponding field in Decision Table's action schema. Expressions can reference one or more fields in the Decision Table operator's input schema. Action column expressions have the same limitations as Condition column expressions.

The supported literal types are:

Type Example Details
Integer 123  
Long 1234l lowercase “L” suffix
Double 123.456  
String “This is a string” Single or double quotes are required if the string contains embedded space or single or double quotes. Use ' or " to embed a single or double quote, respectively.
Timestamp 2016-06-03 10:00:00.000-0400 The hours, minutes, seconds, milliseconds, and timezone values are optional. An optional value must be present if any optional values to the right of it are present. That is, trim values from right to left.