impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Taras Bobrovytsky (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4964: Fix Decimal modulo overflow
Date Mon, 23 Oct 2017 23:20:41 GMT
Taras Bobrovytsky has uploaded a new patch set (#2). (

Change subject: IMPALA-4964: Fix Decimal modulo overflow

IMPALA-4964: Fix Decimal modulo overflow

The modulo operation between two decimals should never overflow. Before
this patch, there would be an overflow if the scale difference between
the two decimals was large. We would try to scale up the one with the
smaller scale, so that the scales matched, which could result in an

We fix the problem by first checking if the scaled up value would fit
into 128 bits by estimating the number of leading zeros in it. If we
detect that 128 bits is not enough, we convert both numbers to int256,
do the operation, then convert back to 128 bits.

- Added some expr tests that excercise the new code path.

Change-Id: I5420201d4440d421e33e443df005cdcc16b8a6cd
M be/src/exprs/
M be/src/runtime/
M be/src/runtime/decimal-value.inline.h
3 files changed, 120 insertions(+), 27 deletions(-)

  git pull ssh:// refs/changes/29/8329/2
To view, visit
To unsubscribe, visit

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5420201d4440d421e33e443df005cdcc16b8a6cd
Gerrit-Change-Number: 8329
Gerrit-PatchSet: 2
Gerrit-Owner: Taras Bobrovytsky <>
Gerrit-Reviewer: Michael Ho <>
Gerrit-Reviewer: Taras Bobrovytsky <>
Gerrit-Reviewer: Tim Armstrong <>
Gerrit-Reviewer: Zach Amsden <>
Gerrit-Reviewer: anujphadke <>

  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message