impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Behm (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4821: Update AVG() for DECIMAL V2
Date Sat, 18 Feb 2017 00:16:23 GMT
Alex Behm has posted comments on this change.

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

Patch Set 3:

Commit Message:

Line 12: 2. precision will be augmented if the scale is adjusted.
In addition to my other comment, I think we should mention some of the limitations here, for
example, that it won't be possible to compute the AVG() of some decimal types at all.
File fe/src/main/java/org/apache/impala/analysis/

Line 337:       // an implicit divide. This is similar to the MS SQL server's behavior which
Suggest these minor fixes and reordering:

AVG() gets at least MIN_ADJUSTED_SCALE decimal places since it performs an implicit divide.
However, the output type is not always the same as SUM()/COUNT(). Our behavior is similar
to MS SQL Server's which takes the max of the input's scale and MIN_ADJUSTED_SCALE.

The observations are ok, but at a high level:
* the type is not the same as SUM()/COUNT()
* the behavior is not the same as MS SQL Server's

It would be good to provide a justification/intuition for why we chose yet another behavior
(also in the commit msg).
File testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test:

Line 208: ====
We should also add tests for those decimal types where AVG() cannot be computed (because we
always overflow).

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I28f5ef0370938440eb5b1c6d29b2f24e6f88499f
Gerrit-PatchSet: 3
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