sundapeng opened a new pull request, #11321: URL: https://github.com/apache/paimon/pull/11321
### Purpose On an aggregation-merge-engine table with `fields.<field>.aggregate-function='product'` on a DECIMAL column, a retraction record (DELETE / UPDATE_BEFORE) divides the accumulated product by the retracting value with a bare `BigDecimal.divide`. Any quotient with a non-terminating decimal expansion — retracting 3.00 from 10.00, or dividing by 7 — throws `ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result`, which propagates out of the merge function and kills the write or compaction job. Whether the job fails depends purely on the data values. Retraction for the `product` aggregate is a documented, supported feature (`docs/docs/primary-key-table/merge-engine/aggregation.mdx`). This divides at the column scale with `RoundingMode.HALF_UP`, the rounding `Decimal#fromBigDecimal` already applies to the result on the next line, so the quotient rounds like every other decimal conversion in the aggregate instead of throwing. Division by zero still throws, consistent with the integral retract paths of `FieldProductAgg` (#7906). Note: #10220 previously proposed the same fix and was closed unmerged without review; the defect is still on master. ### Tests - `FieldAggregatorTest#testFieldProductDecimalRetractNonTerminating`: retracting 3.00 from 10.00 on a DECIMAL(10,2) column returns 3.33 instead of throwing. Fails on master with `ArithmeticException`. - `FieldAggregatorTest#testFieldProductDecimalRetractRounding`: 10 / 4 at scale 0 rounds to 3, pinning `HALF_UP` (the mode `Decimal#fromBigDecimal` uses; `HALF_EVEN` would give 2). ### API and Format No. ### Documentation No. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
