This is an automated email from the ASF dual-hosted git repository.

huaxingao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d001642ac2 [MINOR][SQL] Remove duplicate code for 
`AggregateExpression.isAggregate` usage
2d001642ac2 is described below

commit 2d001642ac2983fad613e435c30c6f09b811858b
Author: Yuming Wang <[email protected]>
AuthorDate: Wed Jun 15 21:38:07 2022 -0700

    [MINOR][SQL] Remove duplicate code for `AggregateExpression.isAggregate` 
usage
    
    ### What changes were proposed in this pull request?
    
    Remove duplicate code for `AggregateExpression.isAggregate` usage.
    
    ### Why are the changes needed?
    
    Make the code easier to maintain.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing UT.
    
    Closes #36886 from wangyum/isAggregateExpression.
    
    Authored-by: Yuming Wang <[email protected]>
    Signed-off-by: huaxingao <[email protected]>
---
 .../org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
index 7635918279a..45e70bdcb6c 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
@@ -301,20 +301,16 @@ trait CheckAnalysis extends PredicateHelper with 
LookupCatalog {
               failAnalysis("Input argument tolerance must be non-negative.")
             }
 
-          case a @ Aggregate(groupingExprs, aggregateExprs, child) =>
-            def isAggregateExpression(expr: Expression): Boolean = {
-              expr.isInstanceOf[AggregateExpression] || 
PythonUDF.isGroupedAggPandasUDF(expr)
-            }
-
+          case Aggregate(groupingExprs, aggregateExprs, _) =>
             def checkValidAggregateExpression(expr: Expression): Unit = expr 
match {
-              case expr: Expression if isAggregateExpression(expr) =>
+              case expr: Expression if AggregateExpression.isAggregate(expr) =>
                 val aggFunction = expr match {
                   case agg: AggregateExpression => agg.aggregateFunction
                   case udf: PythonUDF => udf
                 }
                 aggFunction.children.foreach { child =>
                   child.foreach {
-                    case expr: Expression if isAggregateExpression(expr) =>
+                    case expr: Expression if 
AggregateExpression.isAggregate(expr) =>
                       failAnalysis(
                         s"It is not allowed to use an aggregate function in 
the argument of " +
                           s"another aggregate function. Please use the inner 
aggregate function " +


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to