impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Hecht (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4821: Update AVG() for DECIMAL V2
Date Tue, 21 Feb 2017 18:10:57 GMT
Dan Hecht has posted comments on this change.

Change subject: IMPALA-4821: Update AVG() for DECIMAL_V2

Patch Set 4:

Commit Message:

PS4, Line 25: types

i.e. we can compute AVG() over DECIMAL(38,0) as long as the absolute values are less than
10^32. I think this is more common than actually having values larger than 10^32 when the
column was the result of some decimal arithmetic that produced a type that's "too precise".
File fe/src/main/java/org/apache/impala/analysis/

PS4, Line 338: Our implementation is similar to MS SQL which takes the max of the input's
             :       // and MIN_ADJUSTED_SCALE.
How about explaining why we deviate from SQL Server and from SUM()/COUNT():

Scale is set the same as MS SQL Server, which takes the max of the input scale and MIN_ADJUST_SCALE.
 For precision, MS SQL always sets it to 38. Instead, trim it down to the size that's needed
given that the absolute value of the result must be less than the absolute value of the largest
input. Using a smaller precision allows for better DECIMAL types to be chosen for the overall
expression when AVG() is a subexpression.

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I28f5ef0370938440eb5b1c6d29b2f24e6f88499f
Gerrit-PatchSet: 4
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Michael Ho <>
Gerrit-Reviewer: Alex Behm <>
Gerrit-Reviewer: Dan Hecht <>
Gerrit-Reviewer: Michael Ho <>
Gerrit-HasComments: Yes

View raw message