r7raul1984 commented on code in PR #52554:
URL: https://github.com/apache/spark/pull/52554#discussion_r2416285543


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -2776,6 +2777,71 @@ object RemoveLiteralFromGroupExpressions extends 
Rule[LogicalPlan] {
   }
 }
 
+/**
+ * To optimize performance, filter conditions should be pushed down in 
[[CountIf]] queries
+ * to reduce the volume of data being processed.
+ *
+ * Input Query :
+ * {{{
+ *     SELECT count_if(c1 > 1) FROM ut1
+ *  }}}
+ *
+ * Rewritten Query:
+ * {{{
+ *     SELECT count_if(c1 > 1) FROM ut1 where c1 > 1

Review Comment:
   When there is only one count_if, it can indeed be rewritten as SELECT 
count(*) FROM ut1 WHERE c1 > 1. However, considering the consistency of the 
code logic, I personally feel that it's unnecessary to check the number of 
count_if statements.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to