You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "adrians (via GitHub)" <gi...@apache.org> on 2025/04/22 13:41:31 UTC
Re: [PR] [SPARK-51400] Replace ArrayContains nodes to InSet [spark]
adrians commented on code in PR #50170:
URL: https://github.com/apache/spark/pull/50170#discussion_r2054148711
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -298,6 +299,24 @@ object ReorderAssociativeOperator extends Rule[LogicalPlan] {
}
+/**
+ * The "ArrayContains" node checks if a given value is present in a given array,
+ * being similar to the "IN" predicate.
+ *
+ * This optimization rule replaces the "ArrayContains" nodes working on literal
+ * lists with "InSet" nodes in the expression.
+ */
+object ReplaceArrayContainsWithInSet extends Rule[LogicalPlan] {
+ override def apply(plan: LogicalPlan): LogicalPlan = {
+ plan transformAllExpressions {
+ case ArrayContains(arrayParam: Literal, col)
+ if arrayParam.value.isInstanceOf[GenericArrayData] =>
Review Comment:
I've reformulated that guard-condition. The only effect it had was protecting against `arrayParam.value` being NULL (which would throw an Null-Pointer-Exception in the next line).
--
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