hatchmark build). This page defines what those numbers mean. The tests in
test/node/ check each rule against plain SQL written independently of the engine.
Time
- Time zone. Rows are placed in time in hatchmark.yaml’s
timezone. ATIMESTAMP WITH TIME ZONEvalue is converted to it. A timestamp without an offset (2026-01-31 18:30:00) is read in the source’stimezone, or as UTC when the source sets none, and converted; a non-UTC project gets note HM4016 for such a source. ADATEis a calendar date and is used as it is. - Windows. A range is a span of calendar dates in that time zone, start inclusive and
end exclusive:
{ start, end }dates, a shorthand ({ last: 30, unit: day },{ to_date: quarter },{ last_complete: month }) or a named alias of one (last_30_days). A comparison is the range shifted by whole units (previous_period,previous_yearor{ shift: { unit: week, by: -1 } }), with days clamped to the target month; under amonthorquartershift a first or last day on a month’s end moves to the target month’s end.resolveRange()insrc/compiler/windows.tsis the definition of every range and comparison. A row is in the window when its local time is. - Horizons. A source is complete through its horizon: by default the latest value of the time
column a metric uses, over all rows, ignoring filters. A timestamp gives that instant; a date is
complete through the end of that day. The source’s
freshnesscan measure another column, take a lag off, or fix the date (Data sources). Each build’s DashboardData lists the horizons it used. - latest_data resolves once per dashboard, before any query runs, to the newest horizon the
dashboard reads; the as-of date is its last local date, and every block’s window ends on that
day.
latest_common_datatakes the oldest horizon instead, so no source ends before the others. A source with{ through: as_of }doesn’t vote; with no source left to vote, the build fails with HM4011. A page on which no block reads data has no as-of date and builds without one. Data checks warn when a source is more than a day behind the as-of (HM4010), when a column’s newest value is more than a day after the build machine’s clock (HM4012; the clock never changes the output), and when a block’s window starts after the data it reads ends (HM4013). These data checks run wherever data is read:hatchmark build,check --sqlandexplain. A plainhatchmark checkreads data only for dashboards with a map, to build each map’s match report (HM5041–HM5043); when that data cannot be read,checkfails with the read’s diagnostics rather than skip the report. - Windows end at the horizon. A measure is complete through the earliest horizon of the
sources it reads (a ratio through its laggiest operand) and never past the as-of. The page
decides every window once, from the page horizon (the newest source horizon, never past the
as-of), and every block takes it: KPIs, tables, category charts, time series, their axes and the
period text. A KPI, table or category chart keeps its range’s dates and reads through the
horizon, so it ends on the same day as the charts beside it and the current day’s rows count as
they arrive: the value is marked in progress with the time it reads through.
last_12_monthsas of Oct 31 with orders through 6:54 p.m. reads Nov 1, 2025 to Oct 31, 2026, 6:54 p.m. This holds for to-date ranges,last Ndays, weeks, months, quarters or years andall_timealike; rows after a fixed as-of are ignored. A source that lags inside the page’s window shows the days after its horizon as no data, never 0, and its KPI says how many days behind it is. A last complete unit is never partial: it is the last unit the page horizon completes (September as of Oct 31, 6:54 p.m.), and it compares with the whole unit before it, cut at the same elapsed time when its source lags inside the unit (at the same calendar day for a month or quarter shift, below). The comparison covers the same elapsed time of its own window, in local days and time of day, never past that window’s end (Nov 1 to Nov 26, 2:03 p.m. against Oct 1 to Oct 26, 2:03 p.m.; a complete Feb 28 month-to-date against Jan 1 to Jan 28). When the comparison window is shorter, it is read whole instead (Mar 1 to Mar 31, 2:03 p.m. against all of February). That holds for flows compared withprevious_period,previous_yearor a day, week or year shift. A{ shift: { unit: month } }orquartershift, on any range form, and every comparison of a point-in-time metric (over_timelastorfirst), compare at the same calendar point instead: the cutoff moves by the shift’s months or days, a month’s last day stays a month’s last day (a source read through Sep 30 compares with one read through Aug 31, on a year-to-date page as on alast_12_monthsone), and a cutoff inside a day keeps its time. An explicit{start, end}range names whole days, so in every block it ends at the last complete day, the local midnight at or before the horizon, and its comparison covers the same number of days, except that a complete range of whole months compares with whole months (February 2025 against all of February 2024, Feb 29 included), and a month or quarter shift ends on the same calendar day, a month’s last day on the target month’s last day (Feb 15 to 29, 2024 a month back is Jan 15 to 31), and a first day on a month’s end starts on the target month’s last day (Feb 28, 2026 alone a month back is Jan 31 alone). An explicit range whose first day isn’t complete yet shows no value rather than 0 (empty: "no_complete_day", note HM4024). - Buckets. Time series bucket by local date; weeks start on the week anchor, and quarters and
years on their
MM-DDanchors (hatchmark.yamlanchors, or a block’s{ unit, anchor }grain). The axis lists every bucket of the window, empty ones included. Each series ends at its own horizon instant: buckets after it have no value, and the bucket it cuts is listed inpartialwith the share elapsed in local wall-clock time (incomplete: "hide"leaves such buckets out,"show"draws them plainly, with HM4014 for a flow metric). The window starts at the start of its first bucket, so that bucket is whole, unless the block setsedges: "clip", which marks it partial instead. The cutoff is compared as a UTC instant, so it stays exact inside a repeated fall-back hour, andaxis.window.endAtgives its local time.
Snapshots
A metric withover_time last, first, avg, min or max reads a snapshot table (a source
with snapshot set, or any table that holds a full copy of its rows at each date), never adding up
the copies (RFC 0001 section 3.2).
- A snapshot is one value of the time column: a date, or an instant for a timestamp. Rows that share it are one snapshot; two instants on one day are two snapshots; a row with no time is in none.
- The snapshot is chosen before filters. In each time bucket, or the whole window for a KPI,
table, pie, bar list, map, scatter or category bar,
lastreads the source’s latest snapshot andfirstits earliest, over every row. Filters and segments then keep rows at that snapshot, so selecting a region never moves the date: a region with no rows there is 0. - avg, min and max take each group’s value at every snapshot in the bucket (0 for a sum or
count with no rows there) and average it, or take the smallest or largest.
avgaverages the snapshots present, not calendar days (note HM4040, which stays until calendar-day averaging exists). - Gaps. A bucket with no snapshot is empty, never 0, so a line breaks there. The build warns (HM4015) for complete buckets with no snapshot or whose last snapshot is before their last day.
- Totals (a table’s total row, a split’s total, a stack’s position total) are the metric over
their own bucket or window, never the sum of group values.
last,firstandavgof a sum or count add up across groups;minandmaxdo not (HM4001 for percent of total). - Custom date ranges give the same numbers as the executor. A per-snapshot
count_distinct,medianoravgread withavg,minormaxover time is shown for presets only.
Filters
Metric filters and dashboard select filters compare a column with a value:- A value compared with a date or timestamp column is strict ISO 8601; anything else is HM3009.
A day, zero-padded
YYYY-MM-DD, compares the row’s local calendar date:eq "2026-01-31"matches the whole day,between "2026-01-01"and"2026-01-31"includes all of January 31, andgt "2026-01-31"starts on February 1. A date-time (YYYY-MM-DDTHH:MM, optional seconds and up to 6 decimals) withZor an offset such as-05:00is that exact instant; without one it is wall-clock time in the project time zone. neqandnot_inkeep rows whose column is null: “not West” includes rows whose region is unknown. SQL’s<>would drop them; Hatchmark usesIS DISTINCT FROM. To drop them too, add anot_nullfilter.eq,in,gt,gte,lt,lteandbetweennever match null.- Column names match case-insensitively for ASCII letters, as DuckDB resolves them.
in_tablekeeps rows whose column value appears in another source’s key column, andnot_in_tablekeeps the rest. A null value failsin_tableand passesnot_in_table, and null keys match nothing, so a blank line in an exclusion list never drops a row. Duplicate keys count once. The two columns must have comparable types: integers of any width match each other exactly, text matches text, and columns of one type match each other. Any other pair, such as integer ids against a text, decimal or floating-point key column, is an error (HM2029) that names both types, because converting either side could make different values match.- A segment (
segments/<name>.yaml) is a named list of filters. A metric’ssegmentsadd those filters to the metric’s own, on aggregate and sql metrics alike, so “External revenue” withsegments: [external]reads exactly the rows its filters and every segment’s filters keep. A result that reads a key table is cached against that table’s file too, so editing the list recomputes it.
Groups, totals and empty values
- Null is a group. Rows whose grouping column is null form their own row or series, shown as “(empty)”. It is never confused with a total row.
- Totals are recomputed from rows, never summed: SQL
GROUP BY ROLLUP’s grand total. A distinct count’s total counts each customer once; a ratio’s total divides the two totals. - Ratios divide two metrics, possibly from different sources. Rows match on equal group values, null included. Division by zero or by an empty value is empty (null, shown as ”—”).
- avg is sum over count of non-null values, so it stays right when groups are combined.
- limit keeps the first rows after sorting, ties broken by the group values. It never counts the total row, and the total still covers every row.
- Other (a table’s
other: true) is recomputed from the parts of the rows past the limit: sums and counts add, min and max take the extreme, averages and ratios divide folded sums. Distinct counts, medians, non-additive SQL, any metric read withover_timemin or max, and an average, min or max read withover_timeavg cannot be folded and show ”—” (HM4063). An additive SQL metric that gives a number other than 0 over no rows, such ascoalesce(sum(amount), 99), runs its own SQL over the rows past the limit instead, so Other equals the SQL over those rows. So does any Other whose folded rows include an infinite or NaN value, or whose sum overflows, so Other shows what DuckDB gives over those rows (”—” when that is itself infinite or NaN). - Subtotals come from the query’s grouping sets (SQL ROLLUP), like the total, never from adding the rows below them.
- Empty groups and buckets. Sums, counts and additive SQL metrics with a numeric result are 0
over no rows, and so is a distinct count over a window with no rows. Averages, ratios, medians,
min and max of no rows are empty, as are distinct counts of an empty group or bucket. Rows that
exist but whose values are all NULL stay empty, as SQL SUM does. A SQL metric shows what its SQL
gives over no rows, such as 99 for
coalesce(sum(amount), 99)or 0 forcount(distinct customer), except a segment of a stacked bar or area, which adds nothing to its position. A segment whose rows have only NULL inputs shows that value too, and no number can tell it from a real one, so a stack (plain or 100%) of such a metric, or of one whose value over no rows could not be computed, shows no shares at all: a 100% stack shows ”—” for every share, a plain stack lists no percentages, both keep their values and totals, and the build says why (HM4063). - percentOfTotal is a row’s share of the grand total, for additive metrics only (HM4001).
- Stacked bars and areas carry each position’s total, recomputed from rows like a table’s, and
each segment’s share of it; a 100% stack (
stack: percent) needs additive metrics too (HM4001). See Stacked. - Pies and donuts divide each positive category by the sum of the positive ones; Other sums the
categories past
limit(or, for a SQL metric as above, runs its SQL over their rows), and the total is recomputed from rows. Their metric must be additive (HM4001). See Pie and donut.additive: trueon a SQL metric is checked when a table has a total: if the rows do not add up to the total, build warns with HM4003. - Scatter points evaluate x, y and size per category from that category’s rows, so a ratio divides the category’s sums. A category whose x or y is empty is left out and counted (HM4070), never drawn at 0. See Scatter.
- KPI change.
changePctis the relative change,(value - previous) / |previous|, empty when the previous value is 0 or empty. For percent-formatted metrics it is the difference in percentage points instead (0.012 = +1.2 pp).
Precision
Integer and DECIMAL columns aggregate exactly in DuckDB and are converted to a JavaScript number once; integers are exact up to 2^53 (about 9 quadrillion). Floating-point columns (CSV numbers with a decimal point) sum with compensated (Kahan-Babuska) summation in file order, and an average is that sum divided by the count. Every floating-point result is rounded to 15 significant digits, and tiny values such as 4e-10 are never rounded away. Because the values are added in the same order on every run, a total is the same, byte for byte, however many threads DuckDB uses. File order is fixed when the source is loaded: every source, Parquet included, is read once into a table that keeps the file’s row order, and each row gets its place in that table. It never comes from a column in the data, and column names starting with__hm_ are reserved for
Hatchmark (HM2017). A source path with glob characters (*, ?, [) is a check error
(HM2016), since DuckDB would read it as several files. Should the executor still be given several
files, it takes their rows file by file, with the paths sorted by their UTF-8 bytes.
Floating-point sums are accurate for values within ±1e15. When a metric sums or averages a
floating-point column that holds a larger value, run warns with HM4004: the result is still the
same on every run, but small values next to very large ones may be lost. Store such values in a
smaller unit, as DECIMAL in Parquet, or in separate columns.
Fifteen significant digits hold cents only below 1e13 (ten trillion). When the value a block
reads for a floating-point sum or average (the average itself, not the sum behind it) reaches
±1e13 in any row, time bucket or total, run also warns with HM4004, naming the metric and the
block. Both checks leave out NaN and infinite values. A table whose rows stay below 1e13 still warns when its total reaches it.
Store such values in a larger unit, such as thousands, or as DECIMAL in Parquet.
SQL metrics run on one thread, since their SQL cannot be rewritten. A SQL result that is not a
number (division by zero) is empty, never 0. A SQL metric whose result is floating-point, such as
the SUM or MAX of a DOUBLE column, keeps 15 significant digits like any float result, and run warns
with HM4004 when its value reaches ±1e13 under the same rule. The check reads the result’s type,
so it skips a SQL metric whose result is an integer or DECIMAL. That type alone does not make the
arithmetic exact: CAST(sum(amount) AS DECIMAL(38, 2)) adds DOUBLE values first and only
relabels the result. Store amounts as DECIMAL in the source and sum them as DECIMAL.
HM4004 checks the page as it is built for the dashboard’s default period and filter values,
including every group of a table before limit. Values that appear only under another period
preset, a pick, an Other row or a custom range chosen in the browser are not checked.
Plans
A dashboard has at most one period filter (HM3007): the dashboard’s period and every block read the range it selects. Each planned query carries its source’s file and reader options, so changing a path or a delimiter changes the query’s id and the plan hash. A time bar shows every bucket in order, so it takes no sort or limit (HM3007).Reading files
The DuckDB executor reads CSV with the source’s delimiter and header settings," as quote and
escape, and column types inferred from every row, not a sample. JSON reads the configured format.
Parquet carries its own types. Numbers with leading zeros, such as ZIP codes, stay text.