A table's `limit` truncates the group set *before* sorting, silently dropping the largest groups
Summary
limit=N on a {% table %} does not mean "show the top N". It caps the group set before the sort is applied, so an arbitrary N groups survive and are then sorted among themselves. The largest groups can disappear entirely, with nothing in the UI to indicate that rows are missing. It also suppresses the totals row.
This is a silent-wrong-data bug: the table looks complete and plausible.
Environment
- Evidence CLI v0.9.3 (latest)
- BigQuery direct connector (the mechanism looks dialect-independent)
Steps to reproduce
A dataset with 2,435 distinct values of business_type:
{% table data="upg" limit=500 %}
{% dimension value="business_type" /%}
{% measure value="count(...) as gens" title="Gens" sort="desc" /%}
{% /table %}Actual (limit=500)
Footer reads 1 - 10 of 500 rows. No totals row. First page:
| Business Type | Gens |
|---|---|
| SaaS, Apps & Startups | 3,647 |
| Agency & B2B Services | 3,579 |
| Home & Trade Services | 2,225 |
| … | … |
The single largest group — 5,321 generations — is absent. So are several others.
Expected (remove limit)
Footer reads 1 - 10 of 2,435 rows, totals row present, and the first page matches the warehouse exactly:
| Business Type | Gens |
|---|---|
| (largest group) | 5,321 |
| SaaS, Apps & Startups | 3,647 |
| Agency & B2B Services | 3,579 |
| Home & Trade Services | 2,225 |
Verified against the same aggregation run directly on the warehouse — the unlimited table reconciles row for row; the limited one does not.
Expected behaviour
limit should be applied after ORDER BY, so it yields the top N by the sorted measure. If the current semantics are deliberate, the docs should say so explicitly, since "Maximum number of rows to return from the query" reads as top-N — and a truncated table should be visibly marked as truncated.
Related: null dimension values are counted but never shown
Separately, with raw NULLs in the grouping column, the null group is included in the table's Total but gets no row of its own — so the visible rows sum to less than the stated total. Wrapping the dimension in ifnull(col, '(unclassified)') makes the row appear and the row count goes 2,434 → 2,435, confirming the group was being counted but not rendered.
Impact
High. Both behaviours produce a table that is quietly wrong rather than visibly broken, on the kind of long-tail categorical breakdown that tables are most often used for.
Source: evidence-dev/evidence