Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[SNAP-1083] fix numBuckets handling #15

Merged
merged 1 commit into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
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 @@ -297,7 +297,7 @@ case class OrderlessHashPartitioning(expressions: Seq[Expression],
* in the same partition.
*/
case class HashPartitioning(expressions: Seq[Expression], numPartitions: Int,
numBuckets : Int = 0 ) extends Expression with Partitioning with Unevaluable {
numBuckets: Int = 0) extends Expression with Partitioning with Unevaluable {

override def children: Seq[Expression] = expressions
override def nullable: Boolean = false
Expand All @@ -311,12 +311,14 @@ case class HashPartitioning(expressions: Seq[Expression], numPartitions: Int,
}

override def compatibleWith(other: Partitioning): Boolean = other match {
case o: HashPartitioning => this.semanticEquals(o)
case o: HashPartitioning =>
this.numBuckets == o.numBuckets && this.semanticEquals(o)
case _ => false
}

override def guarantees(other: Partitioning): Boolean = other match {
case o: HashPartitioning => this.semanticEquals(o)
case o: HashPartitioning =>
this.numBuckets == o.numBuckets && this.semanticEquals(o)
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,10 @@ case class EnsureRequirements(conf: SQLConf) extends Rule[SparkPlan] {
// number of partitions. Otherwise, we use maxChildrenNumPartitions.
if (shufflesAllChildren) defaultNumPreShufflePartitions else maxChildrenNumPartitions
}
val numBuckets = {
children.map(child => {
if (child.outputPartitioning.isInstanceOf[OrderlessHashPartitioning]) {
child.outputPartitioning.asInstanceOf[OrderlessHashPartitioning].numBuckets
}
else {
0
}
}).reduceLeft(_ max _)
}
children.zip(requiredChildDistributions).map {
case (child, distribution) =>
val targetPartitioning = createPartitioning(distribution,
numPartitions, numBuckets)
numPartitions)
if (child.outputPartitioning.guarantees(targetPartitioning)) {
child
} else {
Expand Down