Repository navigation
Description
A null field value - the natural way a client says "no measurement here" - is stored and read back as a real
0.0 rather than as the absent marker, so it is counted as a sample by AVG and beats every real value in MIN.
This is adjacent to #7694 but not the same question. #7694 decides what an aggregate answers when it holds no
real sample; this is about a value that should have produced no real sample in the first place, and it is
pre-existing on both sides of that decision. Found while verifying #7694.
Repro
Two samples in one bucket, one real and one null:
t.getEngine().appendSamples(new long[] { 1_000L, 2_000L }, new Object[] { 10.0, null });SELECT ts.timeBucket('1h', ts) AS b, sum(value) AS s, avg(value) AS a, min(value) AS mn, count(*) AS c
FROM P GROUP BY bmeasured:
sum=10.0 avg=5.0 min=0.0 count=2.0
avg=5.0is wrong: one real sample of 10.0 was averaged over two, because thenullentered the
denominator. Expected10.0.min=0.0is wrong: thenullbecame a measurement that is smaller than every real one. Expected10.0.sum=10.0is right only by accident - zero is the additive identity, so adding the phantom sample does not
move the total.count=2is correct:COUNTcounts rows, and there were two.
Both storage layers answer identically, so this is not a mutable-versus-sealed divergence:
PROBE-MUTABLE sum=10.0 avg=5.0 min=0.0 count=2.0
PROBE-SEALED sum=10.0 avg=5.0 min=0.0 count=2.0 (after engine.compactAll())
An explicit Double.NaN behaves correctly - it is a Number, so it reaches the accumulator as the absent marker
and is skipped. It is only null that is coerced.
Where it comes from
ColumnDefinition.coerceValue passes null straight through:
public Object coerceValue(final Object value) {
if (value == null)
return null;and the mutable-bucket reader in TimeSeriesEngine turns anything that is not a Number into 0.0 - at both
of its two accumulation sites, TimeSeriesEngine:654 and :700:
else if (columnIndices[r] < row.length && row[columnIndices[r]] instanceof Number n)
rowValues[r] = n.doubleValue();
else
rowValues[r] = 0.0;TimeSeriesNaN.ABSENT is what that branch should produce, and the same branch also covers a row SHORTER than the
column index (columnIndices[r] >= row.length), which is what a row written before an ALTER ... ADD looks like -
so a column added to an existing type reads as a solid line of zeroes over its whole history rather than as a gap.
That second case is untested here and is worth confirming separately.
Suggested fix
Map "no value" to the absent marker at the two TimeSeriesEngine sites, and check the seal/compaction path
encodes the same for a null (the probe above shows the sealed layer agrees with the mutable one today, so
whatever writes the sealed column needs the same treatment). Needs regression tests for AVG and MIN, on both the
mutable and the sealed path, and for the short-row/ALTER ADD case.
Scope note
Worth deciding deliberately, because this changes query answers for data already stored: every AVG and MIN
over a column with nulls moves. That is why it is filed rather than folded into #7694's contract PR.
Activity
fix(#7732, #7743): the crash-recovery commit, and the absent marker o…
fix(#7743, #7741): keep an undefined total, and name the snapshot-ins…
refactor(#7732): one ownership primitive for the whole engine, and th…
refactor(#7741, #7743): one spelling of absence, one set of quarantin…
test(#7733, #7743): the projection index arithmetic on its own, and t…
fix(#7740): keep the declared column order, and refuse a restore that…
docs(#7743, #7741): name two invariants the last review had to infer
Merge pull request #7747 from ArcadeData/fix/issue-7733-7740-7741-774…
lvca commentedon Sep 17, 2026
Fixed in #7747, merged into
mainfor 26.10.1.Writing
nullfor a measurement - the natural way to say "no reading here" - stored a real0.0. SoAVGdivided by that phantom sample andMINreturned the zero instead of your smallest real value.A
nullis now stored as "no measurement" onDOUBLEandFLOATcolumns, on both the recent and the compacted data, and it reads back as SQLNULL.SUM,AVG,MINandMAXskip it, exactly as they skip aNULLin SQL, whileCOUNT(*)still counts the row. An integer column has nowhere to record absence, so anullthere is still stored as 0 - unchanged behaviour.Worth knowing before you upgrade: this changes the answers of
AVGandMINfor series where you have been writing nulls. Data already stored as zero stays zero; only new writes are affected.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix(ArcadeData#7733, ArcadeData#7743, ArcadeData#7732, ArcadeData#7740,