ETLMCPData Conveyance Works
Log in Start free
Docs

Filter rule

Which rows a filter rule keeps, why rows with a missing value or a failed calculation drop out, and where the count of removed rows shows.

A filter rule keeps a row only when its expression comes out true for that row. Every other row is removed before delivery: rows where the expression is false, rows where it compares against a missing value, and rows where the calculation fails, such as the logarithm of zero. In the pipeline editor's preview, the rows a filter removes are counted as "struck out". A run keeps no such count: it records the rows it fetched and the rows it delivered.

How a filter decides

A filter rule is written {"op": "filter", "expr": "cost > 0 and clicks >= 10"}; in the editor you pick Filter and type the expression, for example impressions > 100. etlmcp evaluates the expression once per row and turns the result into true or false:

  • A comparison (>, <, >=, <=, ==, !=) is true or false. Equality is ==; a single = is refused when you save.
  • and, or and not combine comparisons, and parentheses group them.
  • An expression with no comparison counts as true unless its value is zero, empty or false. cost on its own keeps the rows with spend and removes the rows where cost is zero or empty.

Rows that pass go on to the next rule in the list; the rest are gone for every later rule. Rules run in order, so a filter placed after a group rule tests the grouped rows, not the daily ones.

Missing values

A comparison where either side is empty is false. A row with no cost value is removed by cost > 0 and by cost <= 0 alike. If you want to keep rows with an empty value, test for them on purpose: not cost > 0 is true for empty and zero cost alike.

Arithmetic treats an empty value in different ways depending on the operator:

In the expression With an empty value Effect on the filter
+ or - the empty value counts as 0 cost + 1 > 0 keeps a row with no cost
/ or % by an empty value or by 0 the result is empty conversion_value / cost > 2 removes rows with no spend
* or ** the calculation fails the row is removed
a function such as ln, sqrt or round the calculation fails the row is removed

A platform metric named extra.<name> that a row does not have is empty for that row, so a comparison on it is false and the row is removed.

Calculations that fail

When the expression cannot be worked out for one row, that row is removed and the filter moves on. This covers math that has no answer, such as ln(cost) when cost is 0 or sqrt of a negative number, and the empty-value cases in the table above. Dividing an empty value, as in conversion_value / clicks with no conversion value, fails the same way.

Some problems stop the whole rule list instead of removing rows. When you save, etlmcp tries the expression once against stand-in values and refuses it if a name, a function or the syntax is wrong; Transform validation errors explains each message. The check accepts the base metric columns, currency, date and any extra. name. A filter cannot name a column that an earlier derive rule creates, so write a ratio out in full, as conversion_value / cost > 2. A problem that only appears on real rows, such as a filter on cost after a select rule removed that column, fails the run as a whole and is not retried; see run statuses.

Where removed rows are counted

The pipeline editor previews your rules on a sample of the source's stored rows, or on a demo row when the source has no stored rows yet. Its summary line shows how many rows remain after the rules and how many were struck out. That struck-out figure is the number of rows all the filter rules in the list removed together; other rules that change the row count, such as group or limit, do not add to it.

A finished run records rows_in, the rows fetched from the platform, and rows_out, the rows delivered; Get a run returns both. The difference is not a filter count: other rules such as group change the row count too, and some destinations receive the whole stored history rather than only the run's dates.

What a filter does not change

A filter shapes what the destination receives, not what etlmcp stores. The rows it removes stay in your workspace's stored data, and query_data reads that data before any transform rule. A pipeline holds at most 50 rules, and one expression is at most 2000 characters.

Related