Skip to content
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,19 @@ case class HiveTableScanExec(
}

override def output: Seq[Attribute] = attributes

override def sameResult(plan: SparkPlan): Boolean = plan match {
Copy link
Contributor

Choose a reason for hiding this comment

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

why the default one doesn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

left.cleanArgs == right.cleanArgs in defalut sameResult return false, because equals in MetastoreRelation compare the output(AttributeReference) and exprIds are diff. We need to erase the exprId.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I think all leaf nodes suffer this problem, can you follow the way how they fix it? e.g.

  override def sameResult(plan: LogicalPlan): Boolean = {
    plan.canonicalized match {
      case LocalRelation(otherOutput, otherData) =>
        otherOutput.map(_.dataType) == output.map(_.dataType) && otherData == data
      case _ => false
    }
  }

Copy link
Contributor Author

@watermen watermen Sep 12, 2016

Choose a reason for hiding this comment

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

ReuseExchange work in parquet/orc format, because FileSourceScanExec has override the sameResult.

case other: HiveTableScanExec =>
val thisPredicates = partitionPruningPred.map(cleanExpression)
val otherPredicates = other.partitionPruningPred.map(cleanExpression)

val result = relation.sameResult(other.relation) &&
output.length == other.output.length &&
output.zip(other.output)
.forall(p => p._1.name == p._2.name && p._1.dataType == p._2.dataType) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

does the name matter? I'm not quite sure, but LogicalRelation only checks data type

Copy link
Contributor Author

@watermen watermen Sep 20, 2016

Choose a reason for hiding this comment

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

For example, the full output of table src is (key: Int, value: Int), and output1 is (key: Int), output2 is (value: Int), their(output1, output2) dataType are same, but they are diff and can't be resued.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thisPredicates.length == otherPredicates.length &&
thisPredicates.zip(otherPredicates).forall(p => p._1.semanticEquals(p._2))
result
case _ => false
}
}