You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Value sign: subtraction of opposite-sign operands is Unknown instead of the left operand's sign #1269
sum(rate(requests_total[5m])) - min(temperature_below_zero) over a counter (non-negative) and a source whose value is declared non-positive: the result is non-negative minus non-positive, which is non-negative, but the memo gives its value column the sign Unknown. Any error contract that needs a value of one sign (for example a relative error over a sum) then cannot use it, so a summary candidate above it is not offered.
Where
arithmetic_sign in crates/types/src/stages/logical/column_properties.rs (on the #1230 branch) handles +, * and /; every other operator, - included, falls into the Unknown arm. It is shared by vector BinaryOp and scalar expressions, so both lose the sign.
Proposed rule
Subtraction is addition of the negated right operand: arithmetic_sign(Sub, l, r) = arithmetic_sign(Add, l, flipped(r)):
left
right
left - right
NonNegative
NonPositive
NonNegative
NonPositive
NonNegative
NonPositive
same sign, or either Unknown
Unknown
Under the sign-bit definition of ValueSign this holds for zeros and infinities too (x - y with both sign bits as above never yields NaN: +Inf - (-Inf) = +Inf).
This only adds precision; today's Unknown is safe. Found in the review of #1230 (part of #1207).
Done when
arithmetic_sign covers Sub as above, with no second copy of the add rule.
Tests for both rows (vector and scalar forms) and for a same-sign subtraction staying Unknown.
Activity
feat(stage0, types): memo hash-consing, group properties (column_sign…