c21 commented on a change in pull request #31542:
URL: https://github.com/apache/spark/pull/31542#discussion_r576639301



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/OptimizeMetadataOnlyQuery.scala
##########
@@ -52,8 +52,10 @@ case class OptimizeMetadataOnlyQuery(catalog: 
SessionCatalog) extends Rule[Logic
     plan.transform {
       case a @ Aggregate(_, aggExprs, child @ PhysicalOperation(
           projectList, filters, PartitionedRelation(partAttrs, rel))) =>
-        // We only apply this optimization when only partitioned attributes 
are scanned.
-        if (AttributeSet((projectList ++ 
filters).flatMap(_.references)).subsetOf(partAttrs)) {
+        // We only apply this optimization when only partitioned attributes 
are scanned and filters
+        // are deterministic.
+        if (AttributeSet((projectList ++ 
filters).flatMap(_.references)).subsetOf(partAttrs)
+          && filters.map(_.deterministic).forall(identity)) {

Review comment:
       nit: why not just `filters.forall(_.deterministic)`? 




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to