Security Data Works

Detection portability

Same detection, different answer

The morning I stopped trusting dashboards, I was reconstructing an incident at a regulated utility and the timeline wouldn't settle, with sessions tearing down before they were built and connections landing hours out of order, and only after I'd ruled out my own query and my own parsing did I check whether the firewall clocks agreed. They didn't, because the fleet had been stood up over years by different people in different regions, and the same instant could be stamped as much as eighteen hours apart depending on which box you asked.

I wrote that story up in The parsing layer nobody owns, and the migration essay Migrating 800 detection rules has a quieter cousin of it in the anonymized composite migration it describes, where twelve rules came back with 5–15% fewer alerts on the SQL side because the old platform ran UTC and the new engine ran local time. The firewall story is about data that arrived wrong, and the migration one is already half about the engine, so what I wanted to know in the lab was whether data that arrives right, byte-identical in the same Parquet file, gives the same detection answer on every engine you might point at it, and what I found is that it mostly does, until the detection touches a NULL, a time window, a case-insensitive match or a nested list, and many production detections touch at least one of those.

This essay is the practitioner companion to The query engine returned the wrong answer and didn't tell you, which reports the headline NULL and timezone numbers from the first bench below as part of an argument for why a verification gate exists. This one is about what goes on the pre-cutover checklist, query shape by query shape, so that the engine you migrate onto gives you the answer your old rule gave, or at least tells you where it won't, and most of the checklist items below were measured on 2026-11-16 rather than reasoned out.

Reading time: about 13 minutes. Evidence tier: B for the two lab benches and the Sigma lab run (first-party, single machine, deterministic, synthetic data); A for SQL three-valued logic and the Sigma rules specification; the migration case is the anonymized composite from that essay.

Grid titled Same Parquet, same one-hour window, 600 rows or 0 depending on the engine. Under a New York session zone, four column and literal combinations run on DuckDB, DataFusion and chDB: a UTC column with a naive literal returns 0, 600 and 0; a naive column with a naive literal returns 600, 600 and 0; a UTC column with a UTC literal returns 600 on all three; a naive column with a UTC literal returns 0, 600 and 600, with every zero in red. Under a UTC session all three engines return 600 in every row.
SDW Lab timezone bench, re-run on 2026-11-16 on DuckDB 1.5.3 and 2.0.0, DataFusion 53.0.0 and 55.0.0, and chDB 4.1.8 and 4.4.0, with identical results on both build sets, Tier B (single machine, synthetic data). 600 is the UTC-correct count of the 1,200 instants, and DuckDB's zeros follow the SQL standard's reading of a naive literal.

Method

The two benches

Two small, deterministic benches sit under this essay, both Tier B on a single machine, run first in June 2026 and again on 2026-11-16 in fresh environments, once on the June builds and once on current ones, so every per-engine result below names its versions and should be re-run before anyone repeats it as current.

  • The first, ocsf-temporal-null-coercion, writes a 370-row file with a string column holding allow1 (100 rows), allow2 (150), evil (50), the empty string (30) and NULL (40), plus an integer column, and a second file of 1,200 timestamps on a six-second cadence starting at 12:00:00 UTC, written once as UTC-adjusted (timestamp[us, tz=UTC]) and once as naive (timestamp[us]). It runs the same SQL on DuckDB, DataFusion and chDB (1.5.3, 53.0.0 and 4.1.8 in June; 2.0.0, 55.0.0 and 4.4.0 in November) and checks each answer against an explicit SQL-standard or UTC-correct truth.
  • The second, ocsf-nested-type-fidelity, writes 1,000 OCSF-shaped events with src_endpoint and dst_endpoint structs and an observables[] list of structs, and asks the nested questions a hunt actually asks on the same three engines plus Polars (1.41.2 in June, 2.1.0 in November), with each engine given its own best expression as of June, one of which has since been overtaken (below).

Neither bench uses real telemetry, and that's deliberate, because a bench like this only works if the right answer is known in advance, so what I'd carry into anyone else's environment is the per-engine behavior, since the counts belong to the synthetic files. Every timezone number below comes from a session whose zone was set explicitly on each engine and read back into the results, because DataFusion ignores the process TZ variable, so setting the zone at the process level alone never gives it a non-UTC session.

Identical everywhere

The traps that travel with you

Most of the NULL behavior the first bench tested came out identical across the three engines, on both build sets, and I think that's the more dangerous half of the result, because a trap that fires the same way everywhere is one a cross-engine comparison will never catch, since two engines agreeing says nothing about whether either of them matches what the rule was meant to do.

  • s <> 'allow1' returned 230 everywhere, which is correct by three-valued logic and quietly leaves out the 40 NULL rows, so a "not equal to the approved value" detection never sees an event where the field didn't populate.
  • s NOT IN ('allow1','allow2') returned 80 everywhere (the 50 evil rows plus the 30 empty strings), with the NULLs dropped again, so an allowlist rule has the same blind spot.
  • count(s) returned 330 against count(*) at 370, so a rate or threshold computed with count(col) undercounts exactly the rows that are missing the field, which in security data are often the rows you'd most want to look at.
  • s = '' returned 30 and s IS NULL returned 40, so the empty string and NULL are different things on every engine, and a pipeline that turns one into the other on ingest changes every rule that tests either.
  • i = '5' returned 60 everywhere, the same as i = 5, because each engine reconciled the types the same way; that is convenient in a port, though I would not count on it across engines I haven't tested, since an engine is free to raise instead.
  • LIKE '%ignore previous instructions%' over a column with one mixed-case and twenty lower-case copies of that phrase returned 20 on all three, missing the mixed-case one, while ILIKE and lower(c) LIKE both returned 21.

Traps that travel · which rows each predicate sees

Which of the 370 rows each SQL predicate countsA bar of 370 rows split into allow1 (100), allow2 (150), evil (50), empty string (30) and NULL (40, in red). Below it, four predicates and the rows they count: s not equal to allow1 returns 230, spanning allow2, evil and the empty strings; s NOT IN allow1 and allow2 returns 80, the evil rows and empty strings; count(s) returns 330, everything except NULL; and s IS NULL returns 40, the only predicate that sees the NULL rows.Three of these four predicates never see the 40NULL rowsThe 370-row test column, and which rows each predicate counts. Identical onevery engine tested.allow1100allow2150evil50''30NULL40370 rowss <> 'allow1'230s NOT IN ('allow1','allow2')80count(s)330s IS NULL40
Three-valued logic drops the red NULL rows from every comparison, so the not-equal rule, the allowlist rule and a threshold built on count(s) all count around them, and only an explicit IS NULL finds them. Because DuckDB, DataFusion and chDB all agree here, a cross-engine comparison can't catch it. SDW Lab ocsf-temporal-null-coercion, synthetic data, single machine, Tier B.

Little of that is news to someone who has written SQL for a while, but it is news to a detection written in KQL, where a string column has no NULL and a missing value arrives as an empty string (Microsoft's Kusto null-values documentation, Tier B), so col != "x" matches the event that never had the field, or in Sigma, whose string matching ignores case by specification, because whoever wrote that rule never had to think about three-valued logic or about what LIKE does with capital letters. When a rule moves from SPL or KQL or Sigma into SQL, those paths are where the rewritten rule and the original start to disagree, and the disagreement will look the same on every SQL engine you test against, so the test has to be against the old platform's answer or a known truth.

Engine-dependent

The traps that change with the engine

Two shapes gave different answers depending on which of the three engines ran them, over the same bytes, on both build sets, and a third depends on an engine most teams never benchmark, the one the Sigma backend was written for.

The first is the allowlist with a NULL in it. Write count(*) WHERE s NOT IN ('allow1','allow2', NULL), which is what you get when an allowlist is built from a lookup table that picked up an empty row, and by SQL three-valued logic the answer is zero, because one NULL in a NOT IN list means the predicate can never be true for any row. DuckDB and DataFusion returned the standard 0, and chDB returned 80 on 4.1.8 and still returns 80 on 4.4.0, with the same split when the list comes from a subquery over a lookup that holds a NULL, and with chDB still at 80 after setting transform_null_in = 1. So on two of the three engines, a "flag everything not on the allowlist" detection went from catching 80 events to catching none, with a clean zero and no error, the moment a NULL got into the list, and on the third it kept working, which is the non-standard behavior. I find that one uncomfortable, because the engines that follow the standard are the ones that fail open, and a team moving between chDB and DuckDB in either direction would see the rule's output change with no change to the rule. The same allowlist written as a NOT EXISTS anti-join returned 120 on every engine, the 80 plus the 40 rows where the field is NULL, so the anti-join doesn't collapse, though it does surface the NULL rows, and adding s IS NOT NULL brings it back to 80 everywhere.

Engine-dependent · the allowlist with a NULL in it

Allowlist detection counts by engine with a NULL in the listA grid of three query forms by three engines. NOT IN with a NULL in the list returns 0 on DuckDB and DataFusion, highlighted in red with no error, and 80 on chDB. A NOT EXISTS anti-join returns 120 on all three, which includes the NULL-field rows. NOT EXISTS plus s IS NOT NULL returns 80 on all three, the intended answer.One NULL in the allowlist sends two of threeengines to zeroThe same “not on the allowlist” detection over the same bytes, three waysto write it.DuckDBDataFusionchDBNOT IN ('allow1','allow2', NULL)the lookup picked up an empty row0no error0no error80NOT EXISTS anti-joinalso surfaces the NULL-field rows120120120NOT EXISTS plus s IS NOT NULLback to the intended answer808080
The zeros are the SQL-standard answer, which is why they are dangerous: the detection goes quiet with a clean result and no error, and only chDB keeps returning 80, the non-standard behavior. Rewriting the rule as an anti-join gives the same count on all three engines, and an explicit IS NOT NULL restores the 80. Same split on the June and November 2026 builds; Tier B, single machine, synthetic data.

The second is the time window. The bench counts rows in [12:00, 13:00) UTC, where the correct answer is 600 of the 1,200 instants, with the session zone set to America/New_York on every engine and read back to confirm it took. The results were identical on the June and November builds.

SessionColumnLiteralDuckDBDataFusionchDB
New YorkUTC-adjustednaive06000
New Yorknaivenaive6006000
New YorkUTC-adjustedexplicit UTC600600600
New Yorknaiveexplicit UTC0600600
UTCeithereither600600600

The mechanics differ by engine, and DuckDB's are the ones the SQL standard describes, since SQL-92 gives a timestamp without a zone the session's zone (§4.5 and §6.1, Tier A), so DuckDB reads the naive column and the naive literal both as New York time and they match, compares the UTC-adjusted column against a literal it reads as noon in New York, which moves the window four hours and empties it, and does the mirror image when the literal is explicit and the column is naive. chDB applies the session zone to both columns whenever the literal is naive. DataFusion got 600 in every row, including under a verified New York session, since it resolves a naive literal against the column's own zone and leaves the session zone out of the comparison, though the session zone is live and does apply when you cast explicitly to TIMESTAMPTZ, which reads the same literal as noon in New York, four hours later in UTC. So the headline result on the UTC-adjusted column (DataFusion 600, DuckDB 0, chDB 0) holds on both build sets, and the rows that matter most for a checklist are the third and the fifth.

No engine is broken on its own terms, but only DuckDB follows the standard's session-zone rule on every row, while DataFusion and chDB each match it on two of the four, and the engines also differ in how they map Parquet's unadjusted timestamps onto a SQL type. So, as with NOT IN, the standard answer on the first row is the one the detection author didn't want, and that is exactly why it matters for detections. Any rule with a time bucket in it (a failed-auth burst over five minutes, a beaconing interval, a "first seen in the last hour") inherits whatever the engine and the session decided, and the same query over the same file returns 600 or zero depending on configuration nobody wrote down, and on continuous telemetry it would return a believable count from the wrong four hours instead of a zero. What the re-run shows is that two different fixes each close the gap on all three engines, either a UTC session for everything, or a UTC-adjusted column compared against a literal that carries its own zone, while an explicit literal against a naive column still breaks on DuckDB. The composite migration case on the site, where twelve rules lost 5–15% of their alerts until one timezone fix went in across all of them, reads to me like a field-shaped version of this table.

The third shape is case. A lab run on 2026-11-09 (atlas-ocsf-observables) compiled Sigma rules with pySigma 2.0.3 and its SQLite backend 2.1.1 and executed the resulting SQL on DuckDB 1.5.3, the engine the run was pre-registered on, and on SQLite, added afterwards. The backend turns Sigma's |contains modifier into LIKE '%…%', which SQLite matches case-insensitively, as the Sigma specification requires ("All values are treated as case-insensitive strings," rules specification 2.1.0, Tier A), and which DuckDB matches case-sensitively. So a rule looking for "ignore previous instructions" missed the planted mixed-case "Ignore previous instructions…" on DuckDB on all three seeds, with zero hits and no error, while the same SQL on SQLite fired on it, along with 20 lower-case benign quotes per seed for a precision of 0.048. Every other pre-registered rule in that run behaved identically on both engines. The LIKE check in the first bench, the last item in the list of traps that travel with you, is the general version of that, and it says DuckDB is not the odd one out, since LIKE was case-sensitive on DuckDB, DataFusion and chDB alike, so it's SQLite's case-insensitive LIKE that makes a backend built for it look correct, and every one of the three engines I'd actually migrate onto inherits the miss.

Nested OCSF

The nested question that doesn't port

OCSF events are nested, and a lot of what makes OCSF worth adopting lives in the nesting, so the second bench asked whether a nested question gets the same answer everywhere. One level down it does, since src_endpoint.ip = '10.0.0.1' (500 of 1,000), dst_endpoint.port = 3389 (125), src_endpoint.port = 30000 (250) and len(observables) = 3 (250) returned the same count on all four engines on both build sets, whether the field was reached with DuckDB's dot, DataFusion's bracket, chDB's tuple dot or Polars' struct.field.

The boundary is the list of structs, where "does any observable carry type_id = 21" is the natural way to ask an observables[] question. In June, DuckDB (list_filter with a lambda), chDB (arrayExists) and Polars (list.eval) all expressed it and agreed on 250, and on 1,000 for a type present in every row, while DataFusion 53.0.0 could not express it inside a WHERE clause at all, raising Cannot access field at argument, so the hunt had to be rewritten as an UNNEST subquery there, which returns 250. On 55.0.0 the June expression still raises the same error, but a post hoc probe found that the engine has since gained array_any_match with a lambda, and array_any_match(observables, x -> x['type_id'] = 21) returns 250, though only after the session's SQL parser dialect is set to duckdb, databricks or clickhouse, because under the default generic dialect the same text fails with No field named x. So the capability gap closed, behind a parser setting, and the same query text now errors or returns 250 on one engine depending on configuration nobody wrote down, which is the timezone lesson again.

The November run also turned up a break inside one engine's upgrade, because DuckDB 2.0.0 refuses the x -> x.type_id = 21 lambda the June harness used, with a binder error naming the arrow syntax as deprecated, while the newer lambda x: x.type_id = 21 form returns 250 on both 1.5.3 and 2.0.0. Both of those fail loudly, which is the better failure, but they are still porting costs, one across engines and one across a single engine's upgrade, and they're part of why teams flatten observables into their own columns or a side table before querying, trading some schema fidelity for a query that runs the same way everywhere, though the cross-engine half of that reason narrowed this year. The flattening essay argues the other side of that trade, and I think both are right about different workloads.

A different layer

Why this sits under the reader bugs

The site's earlier answer-equivalence work found two of twelve engines silently wrong on byte-identical data, a chDB Bloom-filter pushdown that undercounted equality predicates and a fastparquet dictionary decode, and the June version-currency pass found the chDB one fixed in 4.1.9 while fastparquet 2026.5.0 was still wrong. Those are reader defects, and a point release can fix them. What the two benches here show is a different layer, query semantics and type-system capability, where the divergences are either an engine departing from the standard by design or a capability gap with no bug to file, and five months and a major DuckDB version later the semantic divergences were all still there, while the one capability gap closed only behind a parser setting. That's why I'd put the checks below into the migration plan itself instead of hoping an engine upgrade takes care of them.

The same evidence also cuts the other way in a debate I haven't settled, since Hughes and Lebonitte's July 2026 multi-engine lakehouse series for Snowflake (Tier C, vendor) argues for keeping curated, high-compliance data on a single governed engine, and divergences like these are part of why that advice exists. My read is that a migration onto open tables can manage them with the checklist below and a standing equality gate, and that a team which runs its whole detection layer on one engine avoids most of them, which is a reasonable choice for a small SOC as long as it knows that's the trade it made.

Before cutover

The pre-cutover checklist

This is the part I'd hand to a team the week before they start porting rules, and the items are cheap because the data is already in an open format and running a second query costs nothing but compute.

  • Pin every engine's session timezone to UTC in the connection setup, read the setting back in the same code, and keep that code in the detection repo next to the rules, because DuckDB, chDB and DataFusion each have their own knob and the re-run showed a UTC session gives 600 on every engine, column and literal combination.
  • Pin and read back each engine's SQL parser dialect next to the timezone setting, because DataFusion 55.0.0 answered the observables[] question only with datafusion.sql_parser.dialect set to duckdb, databricks or clickhouse, and the same text failed under the default.
  • Store event time as UTC-adjusted timestamps (isAdjustedToUTC=true in Parquet) at ingest, so the engine never has to guess what a naive value meant, and treat any naive timestamp column as a parsing defect to fix upstream.
  • Write time-window literals with an explicit zone, since against a UTC-adjusted column that held at 600 on all three engines even under a New York session, and add one test per time-bucketed rule that counts a known window against a planted truth on every engine you run.
  • Keep NULLs out of allowlists and blocklists at the source: build them with WHERE value IS NOT NULL, fail the load if one appears, and prefer NOT EXISTS over NOT IN for allowlist rules, since the anti-join returned the same count on all three engines with a NULL in the list, then decide on purpose whether the NULL-field rows it surfaces belong in the result.
  • Decide, rule by rule, whether a missing field should match, and write it explicitly (col <> 'x' OR col IS NULL) wherever the original platform matched missing fields, because SQL won't do it for you.
  • Use count(*) for event counts and count(col) only where you mean "events that have this field", and check every threshold rule for which one it uses.
  • Check how every case-insensitive match in the source rules (Sigma's contains, startswith and endswith, for a start) compiles for each target engine, and where a backend emits plain LIKE, rewrite it as ILIKE or a lower() comparison, then test it with a mixed-case planted value, keeping in mind that the lab probe used ASCII values only.
  • Keep the empty string and NULL distinct through the pipeline, or normalize one into the other deliberately and once, and then re-test every rule that tests either.
  • For OCSF observables[] and other list-of-struct fields, run each hunt on every engine in the plan before cutover, and where one engine can't express it, choose between a per-engine rewrite and a flattened side table before you find out mid-incident.
  • Read each engine's deprecation notes and run the battery with deprecated syntax disabled before an upgrade, because a major version can reject syntax a rule depends on, as DuckDB 2.0.0 did with the arrow lambda, and re-run it after every upgrade, including the boring ones.
  • Run the answer-equality gate over a planted-truth corpus on every engine and every upgrade, and compare against the old platform's output for the same window, since cross-engine agreement alone misses the traps that are identical everywhere.

Limits

What I don't know yet

The per-engine table now covers two build sets five months apart, and the semantic behaviors in it held across both while the one capability gap closed behind a parser setting, which makes me more comfortable calling it a pattern than I was in June, but it is still three SQL engines and Polars on one machine against synthetic files. I haven't extended either bench to ClickHouse server, Trino or Spark, which are the engines a lot of security teams would actually port onto, and SQLite appears here only through the Sigma run, so I haven't tested it beyond that one rule set. The case-sensitivity result rests on an agent-run, independently re-run lab result whose pre-registration I haven't reviewed myself, and the 2026-11-16 probe confirms the mechanism but not that run's rule-level numbers. The November re-run and the probes after it were also run by an agent session and are single-pass, with no independent verification yet. Those gaps are cheap to close, and until they're closed I'd read the table as a snapshot of the builds it names, and the checklist as the part I expect to hold whichever builds come next.