Skip to content

Commit 7dcfe91

Browse files
committed
fix test error
1 parent 34c7001 commit 7dcfe91

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,14 @@ trait ConstraintHelper {
8383
inferredConstraints -- constraints
8484
}
8585

86-
private def replaceConstraint(
87-
constraint: Expression,
88-
source: Expression,
89-
destination: Expression): Expression = constraint transform {
90-
case e: Expression if e.semanticEquals(source) => destination
91-
}
92-
9386
private def replaceConstraints(
9487
constraints: Set[Expression],
9588
source: Expression,
96-
dest: Expression): Set[Expression] = {
97-
constraints.map {
98-
case b @ BinaryComparison(left, right) =>
99-
(replaceConstraint(left, source, dest), replaceConstraint(right, source, dest)) match {
100-
case (Cast(Cast(child, _, _), dt, _), replacedRight)
101-
if dt == child.dataType && child.dataType == replacedRight.dataType =>
102-
b.makeCopy(Array(child, replacedRight))
103-
case (replacedLeft, Cast(Cast(child, _, _), dt, _))
104-
if dt == child.dataType && child.dataType == replacedLeft.dataType =>
105-
b.makeCopy(Array(replacedLeft, child))
106-
case (replacedLeft, replacedRight) =>
107-
b.makeCopy(Array(replacedLeft, replacedRight))
108-
}
109-
}
110-
}
89+
destination: Expression): Set[Expression] = constraints.map(_ transform {
90+
case e: Expression if e.semanticEquals(source) => destination
91+
}).map(_ transform {
92+
case Cast(e @ Cast(child, _, _), dt, _) if e == destination && dt == child.dataType => child
93+
})
11194

11295
/**
11396
* Infers a set of `isNotNull` constraints from null intolerant expressions as well as

0 commit comments

Comments
 (0)