spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@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
Date Tue, 04 Feb 2020 13:18:33 GMT
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


Mime
View raw message