Query debugging and missing fields
Separate errors from empty results
A syntax error prevents a valid query; an empty result may be legitimate. A missing column can signal schema drift, whereas a present column containing null means a particular value is unknown. Check the engine error, table existence, permission, time bounds and schema before changing detection logic.
Work from known records
Use the fixed offline dataset. Count all rows, restrict the window, filter denied outcomes, then count known and unknown actors separately. If a new filter drops every row, inspect just that predicate and its type. In the fixture actor is nullable; treating it as an empty string would erase the distinction between absent and empty.
Synthetic error cases
SQLite SELECT missing_column FROM events raises an error, not zero results. WHERE actor = NULL evaluates to unknown and selects no rows; IS NULL selects absent actors. The classroom query WHERE outcome = 'denied' AND minute >= 0 AND minute < 10 has five records. Four have known actors; report the fifth separately. Other engines may represent null differently.
Query cost and regression
Limit the time range and source scope to the analytical need. Project necessary fields and pre-aggregate when that preserves meaning; do not broaden access to resolve a permission error. Save expected result IDs or aggregate counts, include positive and negative examples and compare before approving a rule change. Document late events and incomplete ingestion as caveats.
Practice and next step
Reproduce the missing-column error and the null comparison using SQLite only. Explain why the two outcomes require different investigation steps. Report the absent inventory row and missing actor as data-quality findings. Next, detection engineering will use explicit hypotheses and regression cases rather than interpreting every query match as an incident.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Query debugging and missing fields — knowledge check
Apply SIEM query, aggregation, dialect and debugging principles to fictional scenarios.
What does an unknown column indicate?
How does SQLite check absent actor values?
How many denied records in the fixed window lack actor?
What is the first step after an unexpected empty search?
What should a regression test include?