Repository navigation
Description
What type of bug is this?
Incorrect result
What subsystems are affected?
Storage Engine, Query Engine, Table Engine
Minimal reproduce step
This issue was identified by source inspection. A focused regression test can reproduce it without a full SQL deployment:
- Create an append-mode Mito scan with a nonempty SST whose legacy
FileMetahas no serializednum_rowsfield. For example, serialize a validFileMeta, removenum_rows, and deserialize it; the field defaults to0(unknown). - Use an unfiltered scan with no region partition expression and no other visibility restrictions.
- Observe the results of
ScanInput::total_rows()andScanInput::total_rows_is_exact()for the selected SST. - Check the row-count statistics exposed through
ScannerPropertiesandRegionScanExec::statistics_from_inputs()to DataFusion.
Suggested regression coverage:
- All selected SST row counts are known.
- A mix of known-count and unknown-count SSTs.
- An unknown-count SST together with a memtable.
- An unknown-count SST pruned by the query's time range (it should not affect the selected scan's precision).
- A non-append-mode scan, whose statistics must retain their existing conservative behavior.
What did you expect to see?
If any selected SST has an unknown row count, the scanner must not report an exact total row count. DataFusion should receive unknown/non-exact row-count statistics rather than Precision::Exact. The ordinary scan must still read the SST and return the correct rows.
If all selected SST counts are known and the existing visibility conditions hold, preserve the current exact-statistics behavior.
The fix should be narrowly scoped to the existing scan-statistics contract. It does not require a new COUNT optimization, Parquet footer recovery, a new statistics abstraction, or a CBO rule.
What did you see instead?
The current code appears to report an exact row count even when the count of a selected legacy SST is unknown:
FileMeta.num_rowsdocuments that0may mean unknown, not empty.ScanInput::total_rows()adds SST row counts, including unknown counts as0.ScanInput::total_rows_is_exact()checks region-partition visibility but not whether the selected SST row counts are known.SeqScan,UnorderedScan, andSeriesScanpropagate that exactness flag for append-mode scans.RegionScanExec::statistics_from_inputs()may therefore exposePrecision::Exact(0)or another undercount to DataFusion for an unfiltered scan.
This is a source-level finding; the end-to-end incorrect-result scenario has not yet been reproduced.
What operating system did you use?
Not applicable (identified by source inspection).
What version of GreptimeDB did you use?
main at baa5630119341a8ffc173dd49571917c09df5123 (source inspection).
Relevant log output and stack trace
None. No runtime reproduction or stack trace collected yet.
Activity
[-]fix(mito2): do not report exact scanner row counts for legacy SSTs with unknown num_rows[/-][+]do not report exact scanner row counts for legacy SSTs with unknown num_rows[/+]Aumnertic commentedon Oct 19, 2026
I'd like to work on this issue.
I'll start by adding regression tests for legacy SSTs with unknown num_rows, then fix the scanner statistics so that unknown row counts are not reported as exact, while preserving normal scan behavior.
fix: avoid exact scan row counts for SSTs with unknown counts (Grepti…
fix: avoid exact scan row counts for SSTs with unknown counts (Grepti…
fix: avoid exact scan row counts for SSTs with unknown counts (Grepti…
fix: avoid exact scan row counts for SSTs with unknown counts (Grepti…
fix: backport selected fixes to v1.3 (#10006)