Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Optimizer.scala
  • Loading branch information
pzzs committed May 8, 2015
commit fa461a5469721e3704a27df833a3a85d45b450b0
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,8 @@ object ConstantFolding extends Rule[LogicalPlan] {

// Fold expressions that are foldable.
case e if e.foldable => Literal.create(e.eval(null), e.dataType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not folded by this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the real bug is that InSet does not correctly implement foldable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this proposal is very smart!!


// Fold "literal in (item1, item2, ..., literal, ...)" into true or false directly when all
// elements is literal.
case InSet(Literal(v, _), hSet) => {
val isExists = hSet.contains(v)
if(isExists) Literal.create(true, BooleanType) else Literal.create(false, BooleanType)
}

// Fold "literal in (item1, item2, ..., literal, ...)" into true directly when
// not all elements is literal.
// Fold "literal in (item1, item2, ..., literal, ...)" into true directly.
case In(Literal(v, _), list) if list.exists {
case Literal(candidate, _) if candidate == v => true
case _ => false
Expand Down