You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "wangyum (via GitHub)" <gi...@apache.org> on 2023/07/27 08:01:45 UTC

[GitHub] [spark] wangyum commented on a diff in pull request #42129: [SPARK-44527][SQL] Replace ScalarSubquery with null if its maxRows is 0

wangyum commented on code in PR #42129:
URL: https://github.com/apache/spark/pull/42129#discussion_r1275885210


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -529,6 +530,15 @@ object SimplifyBinaryComparison
         case TrueLiteral EqualNullSafe b if !b.nullable => b
         case a EqualNullSafe FalseLiteral if !a.nullable => Not(a)
         case FalseLiteral EqualNullSafe b if !b.nullable => Not(b)
+
+        case EqualNullSafe(a: ScalarSubquery, b: ScalarSubquery)
+            if a.plan.maxRows.contains(0) && b.plan.maxRows.contains(0) =>
+          TrueLiteral
+        case e: EqualNullSafe => e
+        case BinaryComparison(a: ScalarSubquery, _) if a.plan.maxRows.contains(0) =>
+          Literal(null, BooleanType)

Review Comment:
   Should move it to `ConstantFolding `.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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