From reviews-return-1030329-archive-asf-public=cust-asf.ponee.io@spark.apache.org Tue Feb 4 13:18:34 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id C03B218064E for ; Tue, 4 Feb 2020 14:18:33 +0100 (CET) Received: (qmail 23492 invoked by uid 500); 4 Feb 2020 13:18:33 -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 23480 invoked by uid 99); 4 Feb 2020 13:18:33 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Feb 2020 13:18:33 +0000 From: GitBox To: reviews@spark.apache.org Subject: [GitHub] [spark] Eric5553 commented on a change in pull request #27368: [SPARK-30651][SQL] Add detailed information for Aggregate operators in EXPLAIN FORMATTED Message-ID: <158082231302.21808.130264573860164939.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Tue, 04 Feb 2020 13:18:33 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Eric5553 commented on a change in pull request #27368: [SPARK-30651][SQL] Add detailed information for Aggregate operators in EXPLAIN FORMATTED URL: https://github.com/apache/spark/pull/27368#discussion_r374663862 ########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/AggregateExec.scala ########## @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.execution.aggregate + +import org.apache.spark.sql.catalyst.expressions.NamedExpression +import org.apache.spark.sql.catalyst.expressions.aggregate.AggregateExpression +import org.apache.spark.sql.execution.{ExplainUtils, UnaryExecNode} + +/** + * Holds common logic for aggregate operators + */ +abstract class AggregateExec( + groupingExpressions: Seq[NamedExpression], + aggregateExpressions: Seq[AggregateExpression]) + extends UnaryExecNode { + + override def verboseStringWithOperatorId(): String = { + val allAggregateExpressions = aggregateExpressions + + val keyString = groupingExpressions.mkString("[", ", ", "]") + val functionString = allAggregateExpressions.mkString("[", ", ", "]") + val inputString = child.output.mkString("[", ", ", "]") + val outputString = output.mkString("[", ", ", "]") + s""" + |(${ExplainUtils.getOpId(this)}) $nodeName ${ExplainUtils.getCodegenId(this)} + |Input: $inputString + |Output: $outputString + |Keys: $keyString + |Functions: $functionString Review comment: The column `b` breaks aggregation function check, so I tried with `sum(c) + 1 as abc`. It only shows alias `abc` but not full aggregate expression. We do need to improve for this case. ``` (5) HashAggregate [codegen id : 2] Input: [sum#41L, count#42L, count#43L] Keys: [] Functions: [sum(cast(key#6 as bigint)), count(val#7), count(key#6)] Output: [abc#26L, (count(val) + sum(key))#36L, count(key) FILTER (WHERE (val > 1))#37L] ``` When removed alias, it shows correctly I think. ``` (5) HashAggregate [codegen id : 2] Input: [sum#59L, count#60L, count#61L] Keys: [] Functions: [sum(cast(key#6 as bigint)), count(val#7), count(key#6)] Output: [(sum(CAST(key AS BIGINT)) + CAST(1 AS BIGINT))#55L, (count(val) + sum(key))#53L, count(key) FILTER (WHERE (val > 1))#54L] ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org For additional commands, e-mail: reviews-help@spark.apache.org