peter-toth commented on a change in pull request #27252: [SPARK-29231][SQL]
Constraints should be inferred from cast equality constraint
URL: https://github.com/apache/spark/pull/27252#discussion_r378315491
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala
##########
@@ -62,11 +62,17 @@ trait ConstraintHelper {
*/
def inferAdditionalConstraints(constraints: Set[Expression]):
Set[Expression] = {
var inferredConstraints = Set.empty[Expression]
- constraints.foreach {
+ // IsNotNull should be constructed by `constructIsNotNullConstraints`.
+ val predicates = constraints.filterNot(_.isInstanceOf[IsNotNull])
+ predicates.foreach {
case eq @ EqualTo(l: Attribute, r: Attribute) =>
- val candidateConstraints = constraints - eq
+ val candidateConstraints = predicates - eq
inferredConstraints ++= replaceConstraints(candidateConstraints, l, r)
inferredConstraints ++= replaceConstraints(candidateConstraints, r, l)
+ case eq @ EqualTo(l @ Cast(_: Attribute, _, _), r: Attribute) =>
+ inferredConstraints ++= replaceConstraints(predicates - eq, r, l)
Review comment:
@wangyum I see, but I think currently you are doing something very different
in https://github.com/apache/spark/pull/27518 see details here:
https://github.com/apache/spark/pull/27518#issuecomment-585251432
I would suggest keeping your https://github.com/apache/spark/pull/27518 in
its current form (but amending its title) and open a new one to address
inequalities.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]