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
Use exprId to deal with different qualifiers between child.outout and…
… attributes from conditions.
  • Loading branch information
viirya committed Mar 19, 2016
commit 662c4e35b3c96df69f5c712a28e302abd623231e
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ case class Filter(condition: Expression, child: SparkPlan)
}

// The columns that will filtered out by `IsNotNull` could be considered as not nullable.
private val notNullAttributes = notNullPreds.flatMap(_.references).distinct
private val notNullAttributes = notNullPreds.flatMap(_.references).distinct.map(_.exprId)
Copy link
Member Author

Choose a reason for hiding this comment

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

The attributes from conditions can have different qualifiers than child.output, which makes later indexOf call failed. So here use exprId instead.


override def output: Seq[Attribute] = {
child.output.map { a =>
if (a.nullable && notNullAttributes.contains(a)) {
if (a.nullable && notNullAttributes.contains(a.exprId)) {
a.withNullability(false)
} else {
a
Expand All @@ -112,7 +112,7 @@ case class Filter(condition: Expression, child: SparkPlan)

// filter out the nulls
val filterOutNull = notNullAttributes.map { a =>
val idx = child.output.indexOf(a)
val idx = child.output.map(_.exprId).indexOf(a)
if (idx != -1) {
s"if (${input(idx).isNull}) continue;"
} else {
Expand All @@ -139,7 +139,7 @@ case class Filter(condition: Expression, child: SparkPlan)
// Reset the isNull to false for the not-null columns, then the followed operators could
// generate better code (remove dead branches).
val resultVars = input.zipWithIndex.map { case (ev, i) =>
if (notNullAttributes.contains(child.output(i))) {
if (notNullAttributes.contains(child.output(i).exprId)) {
ev.isNull = "false"
}
ev
Expand Down