Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/22029#discussion_r229708259
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
---
@@ -212,27 +212,27 @@ object ReorderAssociativeOperator extends
Rule[LogicalPlan] {
* 1. Converts the predicate to false when the list is empty and
* the value is not nullable.
* 2. Removes literal repetitions.
- * 3. Replaces [[In (value, seq[Literal])]] with optimized version
+ * 3. Replaces [[In (values, seq[Literal])]] with optimized version
* [[InSet (value, HashSet[Literal])]] which is much faster.
*/
object OptimizeIn extends Rule[LogicalPlan] {
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
case q: LogicalPlan => q transformExpressionsDown {
- case In(v, list) if list.isEmpty =>
+ case i @ In(_, list) if list.isEmpty =>
// When v is not nullable, the following expression will be
optimized
// to FalseLiteral which is tested in OptimizeInSuite.scala
- If(IsNotNull(v), FalseLiteral, Literal(null, BooleanType))
- case expr @ In(v, list) if expr.inSetConvertible =>
+ If(IsNotNull(i.value), FalseLiteral, Literal(null, BooleanType))
+ case expr @ In(_, list) if expr.inSetConvertible =>
val newList = ExpressionSet(list).toSeq
if (newList.length == 1
// TODO: `EqualTo` for structural types are not working. Until
SPARK-24443 is addressed,
// TODO: we exclude them in this rule.
- && !v.isInstanceOf[CreateNamedStructLike]
+ && !expr.value.isInstanceOf[CreateNamedStructLike]
--- End diff --
IIUC, you mean
`expr.values.length > 1` => `expr.value.isInstanceOf[CreateNamedStructLike]`
but `expr.value.isInstanceOf[CreateNamedStructLike]` can't =>
`expr.values.length > 1`
Can you give an example?
Based on my understanding, the code here is trying to optimize a case when
it's not a multi-value in and the list has only one element.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]