You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2022/07/25 18:21:02 UTC

[spark] branch master updated: [SPARK-39784][SQL][FOLLOW-UP] Use BinaryComparison instead of Predicate (if) for type check

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 8628c15d176 [SPARK-39784][SQL][FOLLOW-UP] Use BinaryComparison instead of Predicate (if) for type check
8628c15d176 is described below

commit 8628c15d176a8084b695bbb6ca841831e6fb75d4
Author: huaxingao <hu...@apple.com>
AuthorDate: Mon Jul 25 11:20:41 2022 -0700

    [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](https://github.com/apache/spark/pull/37197#discussion_r928570992)
    
    ### 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 <hu...@apple.com>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala  | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala
index 07d681a6616..41415553729 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala
@@ -154,8 +154,8 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) {
       val r = generateExpression(b.right)
       if (l.isDefined && r.isDefined) {
         b match {
-          case _: Predicate if isBinaryComparisonOperator(b.sqlOperator) &&
-              l.get.isInstanceOf[LiteralValue[_]] && r.get.isInstanceOf[FieldReference] =>
+          case _: BinaryComparison if l.get.isInstanceOf[LiteralValue[_]] &&
+              r.get.isInstanceOf[FieldReference] =>
             Some(new V2Predicate(flipComparisonOperatorName(b.sqlOperator),
               Array[V2Expression](r.get, l.get)))
           case _: Predicate =>
@@ -269,13 +269,6 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) {
     case _ => None
   }
 
-  private def isBinaryComparisonOperator(operatorName: String): Boolean = {
-    operatorName match {
-      case ">" | "<" | ">=" | "<=" | "=" | "<=>" => true
-      case _ => false
-    }
-  }
-
   private def flipComparisonOperatorName(operatorName: String): String = {
     operatorName match {
       case ">" => "<"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org