Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/spark/pull/23171#discussion_r237564039 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala --- @@ -335,6 +343,41 @@ case class In(value: Expression, list: Seq[Expression]) extends Predicate { """.stripMargin) } + private def genCodeWithSwitch(ctx: CodegenContext, ev: ExprCode): ExprCode = { + val (nullLiterals, nonNullLiterals) = list.partition { + case Literal(null, _) => true + case _ => false + } + val listGen = nonNullLiterals.map(_.genCode(ctx)) + val valueGen = value.genCode(ctx) + + val caseBranches = listGen.map(literal => + s""" + |case ${literal.value}: + | ${ev.value} = true; + | break; + """.stripMargin) + + ev.copy(code = + code""" + |${valueGen.code} + |${CodeGenerator.JAVA_BOOLEAN} ${ev.isNull} = ${valueGen.isNull}; + |${CodeGenerator.JAVA_BOOLEAN} ${ev.value} = false; + |if (!${valueGen.isNull}) { + | switch (${valueGen.value}) { + | ${caseBranches.mkString("")} --- End diff -- we should consider that if the number of items is very big, this can cause a compile exception due to the method size limit. So we should use the proper splitting methods for the code
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org