From 36c194e9d37f91b6e8696d76dc759de7c95eae44 Mon Sep 17 00:00:00 2001 From: Zhongshuai Pei <799203320@qq.com> Date: Thu, 7 May 2015 16:02:39 +0800 Subject: [PATCH] Update Optimizer.scala --- .../spark/sql/catalyst/optimizer/Optimizer.scala | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala index 37456f9e6e72c..6dc08606ee704 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala @@ -294,12 +294,10 @@ object ConstantFolding extends Rule[LogicalPlan] { case e if e.foldable => Literal.create(e.eval(null), e.dataType) // Fold "literal in (item1, item2, ..., literal, ...)" into true or false directly. - case In(Literal(v, _), list) => - val isExists = list.exists { - case Literal(candidate, _) if candidate == v => true - case _ => false - } - if (isExists) Literal.create(true, BooleanType) else Literal.create(false, BooleanType) + case InSet(Literal(v, _), hSet) => { + val isExists = hSet.contains(v) + if(isExists) Literal.create(true, BooleanType) else Literal.create(false, BooleanType) + } } } }