Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 10659200C22 for ; Tue, 21 Feb 2017 19:11:01 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0EF9A160B68; Tue, 21 Feb 2017 18:11:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 56CC3160B4F for ; Tue, 21 Feb 2017 19:11:00 +0100 (CET) Received: (qmail 3322 invoked by uid 500); 21 Feb 2017 18:10:59 -0000 Mailing-List: contact reviews-help@impala.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@impala.incubator.apache.org Received: (qmail 3311 invoked by uid 99); 21 Feb 2017 18:10:59 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Feb 2017 18:10:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id B4D7F1A0046 for ; Tue, 21 Feb 2017 18:10:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.362 X-Spam-Level: X-Spam-Status: No, score=0.362 tagged_above=-999 required=6.31 tests=[RDNS_DYNAMIC=0.363, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id HeRJMQ0amApb for ; Tue, 21 Feb 2017 18:10:58 +0000 (UTC) Received: from ip-10-146-233-104.ec2.internal (ec2-75-101-130-251.compute-1.amazonaws.com [75.101.130.251]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id C24335F477 for ; Tue, 21 Feb 2017 18:10:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ip-10-146-233-104.ec2.internal (8.14.4/8.14.4) with ESMTP id v1LIAvKL015262; Tue, 21 Feb 2017 18:10:57 GMT Message-Id: <201702211810.v1LIAvKL015262@ip-10-146-233-104.ec2.internal> Date: Tue, 21 Feb 2017 18:10:57 +0000 From: "Dan Hecht (Code Review)" To: Michael Ho , impala-cr@cloudera.com, reviews@impala.incubator.apache.org CC: Alex Behm Reply-To: dhecht@cloudera.com X-Gerrit-MessageType: comment Subject: =?UTF-8?Q?=5BImpala-ASF-CR=5D_IMPALA-4821=3A_Update_AVG=28=29_for_DECIMAL_V2=0A?= X-Gerrit-Change-Id: I28f5ef0370938440eb5b1c6d29b2f24e6f88499f X-Gerrit-ChangeURL: X-Gerrit-Commit: 56351707826e7e06efc2a28d6f6fc22514773ae7 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 archived-at: Tue, 21 Feb 2017 18:11:01 -0000 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 Gerrit-Reviewer: Alex Behm Gerrit-Reviewer: Dan Hecht Gerrit-Reviewer: Michael Ho Gerrit-HasComments: Yes