What is the problem the feature request solves?
Decimal Divide is currently serialized with two consecutive, equivalent CheckOverflow expressions.
After #5171:
The resulting shape is:
CheckOverflow(type=T, fail=F)
CheckOverflow(type=T, fail=F)
Divide(...)
The native planner only removes a CheckOverflow whose child is a matching WideDecimalBinaryExpr, or fuses one whose child is a decimal Cast; it does not collapse nested CheckOverflow expressions (planner.rs).
On successful array-valued decimal-division batches, both wrappers therefore perform the precision scan in CheckOverflow.evaluate.
Describe the potential solution
Stop DecimalPrecision.promote from wrapping decimal Divide, while retaining the specialized wrapper in CometDivide.convert. That wrapper is required to handle Comet's native decimal-division overflow sentinel correctly.
Acceptance criteria:
- Decimal
Divide serializes to exactly one CheckOverflow.
- Its datatype equals
Divide.dataType.
failOnError is true only for ANSI mode.
- LEGACY and TRY overflow behavior remains null-producing.
- ANSI overflow behavior remains error-producing.
- Existing divide-by-zero behavior is unchanged.
- Add a proto-level regression covering LEGACY, TRY, and ANSI modes.
Additional context
Raised in review of #5171, while fixing #5075.
What is the problem the feature request solves?
Decimal
Divideis currently serialized with two consecutive, equivalentCheckOverflowexpressions.After #5171:
DecimalPrecision.promoteadds an outer wrapper withdatatype = Divide.dataTypeandfailOnError = (Divide.evalMode == ANSI).CometDivide.convertadds an inner wrapper with the same datatype and overflow mode.The resulting shape is:
The native planner only removes a
CheckOverflowwhose child is a matchingWideDecimalBinaryExpr, or fuses one whose child is a decimalCast; it does not collapse nestedCheckOverflowexpressions (planner.rs).On successful array-valued decimal-division batches, both wrappers therefore perform the precision scan in
CheckOverflow.evaluate.Describe the potential solution
Stop
DecimalPrecision.promotefrom wrapping decimalDivide, while retaining the specialized wrapper inCometDivide.convert. That wrapper is required to handle Comet's native decimal-division overflow sentinel correctly.Acceptance criteria:
Divideserializes to exactly oneCheckOverflow.Divide.dataType.failOnErroris true only for ANSI mode.Additional context
Raised in review of #5171, while fixing #5075.