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
Copy file name to clipboardExpand all lines: docs/user/ppl/functions/expressions.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,12 @@ Arithmetic expressions are formed by combining numeric literals and binary arith
15
15
16
16
Long (`BIGINT`) arithmetic operations (`+`, `-`, `*`) in `eval` expressions detect overflow and return an error instead of silently wrapping. Narrower integer operands are widened before arithmetic, so crossing the 32-bit integer boundary does not overflow. Floating-point (`float`, `double`) arithmetic follows IEEE 754 and does not produce overflow errors.
17
17
18
-
`stats sum(integral_field)`widens `TINYINT`, `SMALLINT`, `INTEGER`, and `BIGINT` inputs to an exact `BIGINT` accumulator and checks every addition for overflow. It returns an error as soon as the running sum exceeds the `BIGINT` range. With pushdown enabled, a direct field sum uses a native checked aggregation that validates both shard-local additions and the final cross-shard reduction. When the aggregate cannot be pushed down, Calcite uses `Math.addExact`. Neither path uses OpenSearch's double-based `sum`, so results do not lose low-order precision for large values.
18
+
The accumulator used by `stats sum(integral_field)`depends on whether Calcite pushdown is enabled:
19
19
20
-
For example, summing `4611686018427387904` (`2^62`) and `1` returns the exact `4611686018427387905`.
20
+
- With `plugins.calcite.pushdown.enabled=true` (the default), OpenSearch uses its native double-based `sum`, then the result is checked and narrowed to `BIGINT`. Large in-range sums can lose low-order precision. A small overflow that rounds to a signed `BIGINT` boundary can also be indistinguishable from an in-range sum and may saturate at the boundary instead of returning an error.
21
+
- With `plugins.calcite.pushdown.enabled=false`, Calcite uses an exact `BIGINT` accumulator and `Math.addExact` for every addition. It returns an error as soon as the running sum exceeds the `BIGINT` range.
22
+
23
+
For example, summing `4611686018427387904` (`2^62`) and `1` returns the exact `4611686018427387905` without pushdown. With pushdown enabled, the double accumulator cannot represent the low-order `1`, so the result is `4611686018427387904`.
0 commit comments