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
Remove the Literal pattern matching for NullPropagation
  • Loading branch information
chenghao-intel committed May 5, 2014
commit 68b9fad66b499e667c827a1a0bb1ef8dccaa813e
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ object ColumnPruning extends Rule[LogicalPlan] {
object NullPropagation extends Rule[LogicalPlan] {
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
case q: LogicalPlan => q transformExpressionsUp {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want Up? I believe this means we are going to call evaluate on each foldable node working up instead of just calling it once at the top.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expression.foldable is ok by traveling from top to bottom, while null propagation is opposite. I've put them into different rule objects (ConstantFolding & NullPropagation).

// Skip redundant folding of literals.
case l: Literal => l
case e @ Count(Literal(null, _)) => Literal(0, e.dataType)
case e @ Sum(Literal(c, _)) if(c == 0) => Literal(0, e.dataType)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not like the previous implementation, I didn't add the null value as Child expression for both Sum and Average in the rule, cause Hive will throw semantic exception.

case e @ Average(Literal(c, _)) if(c == 0) => Literal(0.0, e.dataType)
Expand Down