Github user tarekauel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7778#discussion_r35837995
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
 ---
    @@ -107,21 +109,71 @@ case class In(value: Expression, list: 
Seq[Expression]) extends Predicate with C
         val evaluatedValue = value.eval(input)
         list.exists(e => e.eval(input) == evaluatedValue)
       }
    +
    +  override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): 
String = {
    +    if (list.isEmpty) {
    +      s"""
    +        ${ev.primitive} = false;
    +        ${ev.isNull} = false;
    +       """
    +    } else {
    +      val valueGen = value.gen(ctx)
    +      val listGen = list.map(_.gen(ctx))
    +      val listCode = listGen.map(x =>
    +        s"""
    +          if (!${ev.primitive}) {
    +            ${x.code}
    +            if (${classOf[Objects].getName}.equals(${valueGen.primitive}, 
${x.primitive})) {
    +              ${ev.primitive} = true;
    +            }
    +          }
    +         """).foldLeft("")((a, b) => a + "\n" + b)
    +      s"""
    +      ${valueGen.code}
    +      boolean ${ev.primitive} = false;
    +      boolean ${ev.isNull} = false;
    +      $listCode
    +     """
    +    }
    +  }
    +
     }
     
    +/**
    + * Helper companion object in order to support code generation.
    + */
    +object InSet {
    +
    +  @transient var hset: Set[Any] = null
    --- End diff --
    
    @rxin Is there a better way to expose `hset` to the codeGen stuff?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to