viirya commented on code in PR #37176:
URL: https://github.com/apache/spark/pull/37176#discussion_r920465103


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala:
##########
@@ -113,23 +106,15 @@ trait OperationHelper extends AliasHelper with 
PredicateHelper {
 }
 
 /**
- * A pattern that matches any number of project or filter operations on top of 
another relational
- * operator.  All filter operators are collected and their conditions are 
broken up and returned
- * together with the top project operator.
- * [[org.apache.spark.sql.catalyst.expressions.Alias Aliases]] are 
in-lined/substituted if
- * necessary.
+ * A pattern that matches a plan node with only deterministic Project and/or 
Filter above it. It
+ * returns the input plan itself if there is no Project or Filter.
  */
-object PhysicalOperation extends OperationHelper with PredicateHelper {
-  override protected def legacyMode: Boolean = true
-}
-
-/**
- * A variant of [[PhysicalOperation]]. It matches any number of project or 
filter
- * operations even if they are non-deterministic, as long as they satisfy the
- * requirement of CollapseProject and CombineFilters.
- */
-object ScanOperation extends OperationHelper with PredicateHelper {
-  override protected def legacyMode: Boolean = false
+object NodeWithOnlyDeterministicProjectAndFilter {
+  def unapply(plan: LogicalPlan): Option[LogicalPlan] = plan match {
+    case Project(projectList, child) if projectList.forall(_.deterministic) => 
unapply(child)
+    case Filter(cond, child) if cond.deterministic => unapply(child)
+    case _ => Some(plan)

Review Comment:
   Hmm, if it returns `Some` for all other cases, doesn't it mean it matches 
all input plans?



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