cloud-fan commented on code in PR #56499:
URL: https://github.com/apache/spark/pull/56499#discussion_r3503163396
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala:
##########
@@ -77,9 +79,52 @@ trait ConstraintHelper {
inferredConstraints ++= replaceConstraints(predicates - eq -
EqualNullSafe(l, r), l, r)
case _ => // No inference
}
+
inferredConstraints -- constraints
}
+ /**
+ * Infers additional constraints by substituting known attribute-to-literal
bindings into
+ * non-equality predicates. For example, given `a = 5` and `b >= a`, infers
`b >= 5`.
+ *
+ * [[EqualTo]] and [[EqualNullSafe]] predicates are excluded from
substitution targets.
Review Comment:
This opening sentence over-states the `EqualTo` exclusion —
attribute-to-*expression* `EqualTo` (e.g. `b = a + 1`) is a valid substitution
target, exercised by the "into EqualTo expressions" test in
ConstraintPropagationSuite (infers `b = 6`). Only attribute-to-attribute and
cast-form `EqualTo` are excluded (the `filterNot` below). The two sentences
that follow already scope it correctly.
```suggestion
* Attribute-to-attribute (and cast-form) [[EqualTo]] and all
[[EqualNullSafe]] predicates are
* excluded from substitution targets.
```
--
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]