Skip to content

[core] Divide decimal product aggregate at the column scale on retract - #10220

Closed
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-045-field-product-divide
Closed

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-045-field-product-divide

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

FieldProductAgg's retract path divided decimals with a bare BigDecimal.divide, which throws ArithmeticException ("Non-terminating decimal expansion") for any quotient that does not terminate at the divisor scale, for example 1 / 3. A retract row into an aggregation table with a decimal product column then kills the write or compaction job.

This divides at the column scale with RoundingMode.HALF_UP, the same rounding fromBigDecimal already applies on the line below, so the quotient rounds like every other decimal conversion instead of throwing, and retract stays consistent with how the forward agg path rounds its product.

Tests

Added a case in FieldAggregatorTest that retracts 3 out of a DECIMAL(10,4) product column holding 1 and asserts the result is 0.3333, pinning that a non-terminating quotient now rounds at the column scale instead of throwing.

API and Format

No.

Documentation

No.

FieldProductAgg's retract divided decimals with a bare
BigDecimal.divide, which throws ArithmeticException for any
non-terminating or scale-exceeding quotient (e.g. 1 / 3) — a
retract row into an aggregation table with a decimal product column
killed the write or compaction job. Divide at the column scale with
HALF_UP, the same rounding fromBigDecimal already applies, so the
quotient rounds like every other decimal conversion instead of
throwing.

Assisted-by: GLM-5.3
@LuciferYang
LuciferYang marked this pull request as draft October 2, 2026 03:19
@LuciferYang LuciferYang closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant