Dan Hecht has posted comments on this change.

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


Patch Set 4:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/6038/4//COMMIT_MSG
Commit Message:

PS4, Line 25: types
values

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".


http://gerrit.cloudera.org:8080/#/c/6038/4/fe/src/main/java/org/apache/impala/analysis/FunctionCallExpr.java
File fe/src/main/java/org/apache/impala/analysis/FunctionCallExpr.java:

PS4, Line 338: Our implementation is similar to MS SQL which takes the max of 
the input's scale
             :       // 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 http://gerrit.cloudera.org:8080/6038
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

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

Reply via email to