Alex Behm has posted comments on this change. Change subject: IMPALA-4821: Update AVG() for DECIMAL_V2 ......................................................................
Patch Set 3: (3 comments) http://gerrit.cloudera.org:8080/#/c/6038/3//COMMIT_MSG 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. http://gerrit.cloudera.org:8080/#/c/6038/3/fe/src/main/java/org/apache/impala/analysis/FunctionCallExpr.java File fe/src/main/java/org/apache/impala/analysis/FunctionCallExpr.java: Line 337: // an implicit divide. This is similar to the MS SQL server's behavior which takes 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). http://gerrit.cloudera.org:8080/#/c/6038/3/testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test 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 http://gerrit.cloudera.org:8080/6038 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: I28f5ef0370938440eb5b1c6d29b2f24e6f88499f Gerrit-PatchSet: 3 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Michael Ho <k...@cloudera.com> Gerrit-Reviewer: Alex Behm <alex.b...@cloudera.com> Gerrit-Reviewer: Dan Hecht <dhe...@cloudera.com> Gerrit-Reviewer: Michael Ho <k...@cloudera.com> Gerrit-HasComments: Yes