Repository navigation
Document that sum and avg over double precision in dataflows truncate each value to a multiple of 2^-24 #39315
Unanswered
sumaiyaazad
asked this question in
Bug Reports
Replies: 1 comment
|
Draft documentation change up in #39330. Thanks for pointing this out. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Version: Materialize v26.25.0 (aa7b919), Docker image.
What happens
In a materialized view,
sumandavgoverdouble precisiontruncate each finite value toward zero to a multiple of 2^-24 (about 6e-8).minandmaxover the same rows return the original stored float values unchanged. A value smaller than 2^-24 in magnitude becomes 0.How to reproduce
Each group has one row, so the sum should equal the value exactly. Group 4 shows the rounding is toward zero, not down. A constant query such as
SELECT sum(v) FROM (VALUES (0.1::float8)) t(v)returns 0.1, because the planner folds it; only the dataflow path truncates.Why it happens
src/compute/src/render/reduce.rsadds float sums as fixed-pointi128numbers withFLOAT_SCALE_EXP = 24. The code says the values are "mapped to a fixed precision i128 domain to preserve associativity and commutativity", which makes sense for sums that must also support retractions. Thefold_vs_dataflowtests already record the difference between constant folding and dataflow, so this looks intended; the request is only about the user documentation.What we ask
The float type page (https://materialize.com/docs/sql/types/float/) does not mention this. Please document:
sumandavgover floats use fixed point in dataflows;numericavoids this quantization, within its documented precision.Users comparing a view with a batch system would then know what to expect.
All reactions