Skip to main content

Conditions


Purpose

The conditions section allows you to filter source data before any transformation is applied.
It is equivalent to a SQL WHERE clause: only rows matching the condition are processed by the stream.

Conditions are defined at the root level of a .stream.json file.


Basic Structure

Simple Condition

{
"condition": {
"left": "a.storeId",
"op": "==",
"right": "$storeId$"
}
}
  • left: Column reference (source or lookup)
  • op: Comparison operator
  • right: Comparison value (literal, variable, list, or null)

Condition Types

1. Simple Condition

Used when a single comparison is sufficient.

{
"condition": {
"left": "a.status",
"op": "==",
"right": "'ACTIVE'"
}
}

2. Indexed Condition

Indexed conditions are required when building complex logical expressions.

{
"left": "a.status",
"op": "==",
"right": "'ACTIVE'",
"index": 1
}
  • index uniquely identifies the condition
  • Indexes are referenced later in the logic tree

3. Complex Condition (Logical Combination)

Multiple conditions can be combined using logical operators.

{
"condition": {
"conditions": [
{ "left": "a.country", "op": "==", "right": "'FR'", "index": 1 },
{ "left": "a.type", "op": "IN", "right": ["STORE", "WAREHOUSE"], "index": 2 }
],
"logic": {
"left": 1,
"op": "&&",
"right": 2
}
}
}

Resulting logic:

(country == 'FR') AND (type IN ['STORE', 'WAREHOUSE'])

Join Conditions with Lookups

Conditions can reference lookup columns using their alias.

{
"lookups": [
{ "table": "stores", "alias": "b", "columns": [...] }
],
"condition": {
"left": "b.storeType",
"op": "==",
"right": "'RETAIL'"
}
}

Supported Operators

Comparison Operators

OperatorDescriptionExample
==Equality comparison"== 'ACTIVE'"
INValue membership in a listIN ["A", "B", "C"]
is notNot null / existence checkis not null

Logical Operators

OperatorDescription
&&Logical AND
`

Value Syntax

SQL Databases (PostgreSQL, MySQL, SQL Server)

SyntaxUsageExample
"a.column"Source column reference"a.storeId"
"b.column"Lookup column reference"b.storeType"
"$var$"Runtime variable"$storeId$"
"'VALUE'"String literal"'ACTIVE'"
100Numeric literal100
"_raw(...)"Raw SQL expression"_raw(DATE('$startDate$'))"

Example:

{
"right": "_raw(DATE('$startDate$'))"
}

Couchbase

SyntaxUsageExample
#column.X#Column reference by index#column.2#
alias(a).#column.X#Column reference with explicit aliasalias(a).#column.3#
fieldNameField existence checkrecipe
$var$Runtime variable (no quotes)$travelId$

Example:

{
"condition": {
"left": "#column.2#",
"op": "==",
"right": "$travelId$"
}
}

Nested Logical Trees

Complex logical trees can be nested arbitrarily.

{
"conditions": [
{ "left": "a.country", "op": "==", "right": "'FR'", "index": 1 },
{ "left": "a.city", "op": "==", "right": "'Paris'", "index": 2 },
{ "left": "a.status", "op": "==", "right": "'ACTIVE'", "index": 3 }
],
"logic": {
"left": {
"left": 1,
"op": "&&",
"right": 2
},
"op": "&&",
"right": 3
}
}

Logical result:

(country == 'FR' AND city == 'Paris') AND status == 'ACTIVE'

Checklist

Simple Condition

  • Define left
  • Define op
  • Define right

Complex Condition

  • Define conditions[]
  • Assign unique index values
  • Build the logic tree
  • Validate final logical expression