Skip to content

Commit e41e28a

Browse files
dfa1claude
andcommitted
fix(calcite): return exact Long sum, not a promoted Double (S2154)
The ?: ternary 'isFloating ? Double.valueOf(d) : Long.valueOf(l)' undergoes binary numeric promotion — it unboxes both arms and widens the Long to double, so an integer-column SUM was silently returned as a Double, defeating the exact long accumulation. Return via if/else (reference, no promotion). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3f2ae34 commit e41e28a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

calcite/src/main/java/io/github/dfa1/vortex/calcite/VortexAggregates.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ private static Number scanSum(VortexReader reader, String column) {
120120
}
121121
}
122122
}
123-
return isFloating ? Double.valueOf(doubleSum) : Long.valueOf(longSum);
123+
// Return via if/else, not a ?: ternary: a numeric conditional unboxes both branches and
124+
// widens the Long to double, silently turning an integer-column sum into a Double.
125+
if (isFloating) {
126+
return doubleSum;
127+
}
128+
return longSum;
124129
}
125130
}

0 commit comments

Comments
 (0)