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 0DDD5200CD6 for ; Mon, 31 Jul 2017 10:49:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0C590164BB5; Mon, 31 Jul 2017 08:49:04 +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 78FC6164BA7 for ; Mon, 31 Jul 2017 10:49:03 +0200 (CEST) Received: (qmail 53486 invoked by uid 500); 31 Jul 2017 08:49:02 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 53469 invoked by uid 99); 31 Jul 2017 08:49:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Jul 2017 08:49:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ECC6FE02F3; Mon, 31 Jul 2017 08:49:00 +0000 (UTC) From: viirya To: reviews@spark.apache.org Reply-To: reviews@spark.apache.org References: In-Reply-To: Subject: [GitHub] spark pull request #18779: [SPARK-21580][SQL]Integers in aggregation express... Content-Type: text/plain Message-Id: <20170731084900.ECC6FE02F3@git1-us-west.apache.org> Date: Mon, 31 Jul 2017 08:49:00 +0000 (UTC) archived-at: Mon, 31 Jul 2017 08:49:04 -0000 Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/18779#discussion_r130300193 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala --- @@ -1010,7 +1014,16 @@ class Analyzer( s"(valid range is [1, ${aggs.size}])") case o => o } - Aggregate(newGroups, aggs, child) + // If an aggregateExpression is integer, after replaced with this aggregateExpression, the + // groupExpression will be considered as an ordinal still, so we should filter it. + var filterGroups: Seq[Expression] = Nil + newGroups.foreach { ng => + ng match { + case a: Alias => if (!isIntLiteral (a.child)) filterGroups :+= ng + case _ => filterGroups :+= ng + } + } + Aggregate(filterGroups, aggs, child) --- End diff -- Similar to `RemoveLiteralFromGroupExpressions`, we shouldn't drop all grouping expressions if they are all int literals after resolved from `UnresolvedOrdinal`. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org For additional commands, e-mail: reviews-help@spark.apache.org