Rule Syntax for Config Files

Reference for the SQL-like rule parser syntax used in Nomad Media configuration files.

Various Nomad Media config files use a SQL-like rule parser for enabling/disabling processors, profiles, and other configuration aspects. Rules are evaluated against asset properties at processing time.

General Syntax

A rule must be a valid SQL-style expression against an existing or derived asset property.

Single condition:

ImageHeight >= 500

Compound conditions:

ImageHeight >= 500 AND ContentLength = 66992

Grouped with parentheses:

ImageHeight >= 1200 AND (ContentType LIKE '%jpeg' OR ContentType LIKE '%jpg')

Available Properties

Rules can be written against any of the following asset properties:

PropertyExample Value
bucketType3
assetType2
assetTypeDisplay"File"
storageEventName"ObjectCreated:Put"
originalBucketName"nomad-dev-04-system-content-..."
originalObjectKey"Content/Public/Media/venues/file.jpg"
contentLength66992
contentType"image/jpeg"
mediaType1
mediaTypeDisplay"Image"
imageHeight500
imageWidth800
audioTrackCount0
hasAudiofalse

C# Example

string rule = "url LIKE '%content/wsls/2022/09/06/noon 1 hour 9.6.22/%'";
CaseInsensitiveDictionary<object> properties = new CaseInsensitiveDictionary<object>();
properties.SetValue("url", "nomad-dev-04-system-content-rc46y2f3ixyo::Content/WSLS/2022/09/06/...");

bool ruleValue = SqlRuleParserRepository.Value.ProcessRule(rule, properties, null);

Operators

Boolean Operators

Concatenation uses AND, OR, and NOT.

AND has precedence over other operators:

(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'

Comparison Operators

OperatorMeaning
=Equals
<>Not equals
<Less than
>Greater than
<=Less than or equal
>=Greater than or equal
INValue in list
LIKEPattern match

Arithmetic Operators

OperatorOperation
+Addition
-Subtraction
*Multiplication
/Division
%Modulus

String Operators

Use + to concatenate strings. String comparisons follow the CaseSensitive property of the DataSet (can be overridden per table).

Wildcard Characters

Both * and % can be used interchangeably as wildcards in LIKE comparisons.

"ItemName LIKE '*product*'"   -- contains
"ItemName LIKE '*product'"    -- ends with
"ItemName LIKE 'product*'"    -- starts with

Wildcards are not allowed in the middle of a pattern (e.g., 'te*xt' is invalid).

To use a literal * or % in a LIKE clause, wrap it in brackets: [*] or [%].


Parent/Child Relation Referencing

Reference a parent table column by prepending Parent.:

Parent.Price

If a child has more than one parent row, use the relation name:

Parent(RelationName).Price

Reference a child table column in an aggregate function:

Sum(Child.Price)

For tables with multiple child relations:

Avg(Child(Customers2Orders).Quantity)

Aggregates

FunctionDescription
SumSum of values
AvgAverage of values
MinMinimum value
MaxMaximum value
CountCount of records
StDevStatistical standard deviation
VarStatistical variance

Aggregates are performed along relationships or on a single table:

Sum(Price)
Avg(Child.Price)
Avg(Child(Orders2Details).Price)

Functions

CONVERT

Converts an expression to a specified .NET Framework type.

CONVERT(expression, type)

Example:

myDataColumn.Expression = "Convert(total, 'System.Int32')"

Boolean can be coerced to/from: Byte, SByte, Int16–64, UInt16–64, String. DateTime and TimeSpan can only be coerced to/from String.

LEN

Returns the length of a string.

LEN(expression)

Example: Len(ItemName)

ISNULL

Returns the expression value, or a replacement if null.

ISNULL(expression, replacementvalue)

Example: IsNull(price, -1)

IIF

Returns one of two values based on a logical expression.

IIF(expr, truepart, falsepart)

Example: IIF(total>1000, 'expensive', 'dear')

TRIM

Removes leading and trailing whitespace characters (\r, \n, \t, space).

TRIM(expression)

SUBSTRING

Returns a substring of specified length starting at a specified position.

SUBSTRING(expression, start, length)

Example: SUBSTRING(phone, 7, 8)