Skip to content

Commit 8628c15

Browse files
huaxingaodongjoon-hyun
authored andcommitted
[SPARK-39784][SQL][FOLLOW-UP] Use BinaryComparison instead of Predicate (if) for type check
### What changes were proposed in this pull request? follow up this [comment](#37197 (comment)) ### Why are the changes needed? code simplification ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing test Closes #37278 from huaxingao/followup. Authored-by: huaxingao <huaxin_gao@apple.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent c0b86fe commit 8628c15

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) {
154154
val r = generateExpression(b.right)
155155
if (l.isDefined && r.isDefined) {
156156
b match {
157-
case _: Predicate if isBinaryComparisonOperator(b.sqlOperator) &&
158-
l.get.isInstanceOf[LiteralValue[_]] && r.get.isInstanceOf[FieldReference] =>
157+
case _: BinaryComparison if l.get.isInstanceOf[LiteralValue[_]] &&
158+
r.get.isInstanceOf[FieldReference] =>
159159
Some(new V2Predicate(flipComparisonOperatorName(b.sqlOperator),
160160
Array[V2Expression](r.get, l.get)))
161161
case _: Predicate =>
@@ -269,13 +269,6 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) {
269269
case _ => None
270270
}
271271

272-
private def isBinaryComparisonOperator(operatorName: String): Boolean = {
273-
operatorName match {
274-
case ">" | "<" | ">=" | "<=" | "=" | "<=>" => true
275-
case _ => false
276-
}
277-
}
278-
279272
private def flipComparisonOperatorName(operatorName: String): String = {
280273
operatorName match {
281274
case ">" => "<"

0 commit comments

Comments
 (0)