Skip to content

Commit

Permalink
Not optimize In if the list is type of ListQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
dbtsai committed May 25, 2018
1 parent da10307 commit 730b19b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ object OptimizeIn extends Rule[LogicalPlan] {
// 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 In(v, list) if list.length == 1 => EqualTo(v, list.head)
case In(v, list) if list.length == 1 && !list.head.isInstanceOf[ListQuery] =>
EqualTo(v, list.head)
case expr @ In(v, list) if expr.inSetConvertible =>
val newList = ExpressionSet(list).toSeq
if (newList.size > SQLConf.get.optimizerInSetConversionThreshold) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ object RewritePredicateSubquery extends Rule[LogicalPlan] with PredicateHelper {
newPlan = dedupJoin(
Join(newPlan, sub, ExistenceJoin(exists), conditions.reduceLeftOption(And)))
exists
case EqualTo(value, ListQuery(sub, conditions, _, _)) =>
case In(value, Seq(ListQuery(sub, conditions, _, _))) =>
val exists = AttributeReference("exists", BooleanType, nullable = false)()
val inConditions = getValueExpression(value).zip(sub.output).map(EqualTo.tupled)
val newConditions = (inConditions ++ conditions).reduceLeftOption(And)
Expand Down

0 comments on commit 730b19b

Please sign in to comment.