Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/7893#discussion_r36212442
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
---
@@ -97,32 +101,68 @@ case class Not(child: Expression)
/**
* Evaluates to `true` if `list` contains `value`.
*/
-case class In(value: Expression, list: Seq[Expression]) extends Predicate
with CodegenFallback {
+case class In(value: Expression, list: Seq[Expression]) extends Predicate {
override def children: Seq[Expression] = value +: list
- override def nullable: Boolean = true // TODO: Figure out correct
nullability semantics of IN.
+ override def nullable: Boolean = false // TODO: Figure out correct
nullability semantics of IN.
override def toString: String = s"$value IN ${list.mkString("(", ",",
")")}"
override def eval(input: InternalRow): Any = {
val evaluatedValue = value.eval(input)
list.exists(e => e.eval(input) == evaluatedValue)
}
-}
+ override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode):
String = {
+ val valueGen = value.gen(ctx)
+ val listGen = list.map(_.gen(ctx))
+ val listCode = listGen.map(x =>
+ s"""
+ if (!${ev.primitive}) {
+ ${x.code}
+ if (${ctx.genEqual(value.dataType, valueGen.primitive,
x.primitive)}) {
+ ${ev.primitive} = true;
+ }
+ }
+ """).foldLeft("")((a, b) => a + "\n" + b)
--- End diff --
We usually use `mkString("\n")`
---
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]