Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Avoid using AST on inner joins and avoid coalesce after nested loop join filter #3746

Merged
merged 3 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class GpuBroadcastHashJoinMeta(
left, right)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class GpuShuffledHashJoinMeta(
isSkewJoin = false)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class GpuSortMergeJoinMeta(
join.isSkewJoin)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class GpuBroadcastHashJoinMeta(
left, right)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map { c =>
GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ class GpuShuffledHashJoinMeta(
isSkewJoin = false)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class GpuSortMergeJoinMeta(
join.isSkewJoin)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class GpuShuffledHashJoinMeta(
isSkewJoin = false)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class GpuSortMergeJoinMeta(
join.isSkewJoin)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class GpuBroadcastHashJoinMeta(
left, right)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class GpuBroadcastHashJoinMeta(
left, right)
// The GPU does not yet support conditional joins, so conditions are implemented
// as a filter after the join when possible.
condition.map(c => GpuFilterExec(c.convertToGpu(), joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c.convertToGpu(), joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ object GpuFilter extends Arm {
}
}

case class GpuFilterExec(condition: Expression, child: SparkPlan)
case class GpuFilterExec(
condition: Expression,
child: SparkPlan,
override val coalesceAfter: Boolean = true)
extends ShimUnaryExecNode with GpuPredicateHelper with GpuExec {

override lazy val additionalMetrics: Map[String, GpuMetric] = Map(
Expand All @@ -322,11 +325,6 @@ case class GpuFilterExec(condition: Expression, child: SparkPlan)
case _ => false
}

/**
* Potentially a lot is removed.
*/
override def coalesceAfter: Boolean = true

// If one expression and its children are null intolerant, it is null intolerant.
private def isNullIntolerant(expr: Expression): Boolean = expr match {
case e: NullIntolerant => e.children.forall(isNullIntolerant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ class GpuBroadcastNestedLoopJoinMeta(
verifyBuildSideWasReplaced(buildSide)

val condition = conditionMeta.map(_.convertToGpu())
val isAstCondition = conditionMeta.forall(_.canThisBeAst)
val isAstCondition = join.joinType match {
case _: InnerLike =>
// It appears to be faster to manifest the full cross join and post-filter than
// evaluate the AST during the join.
false
case _ => conditionMeta.forall(_.canThisBeAst)
}
join.joinType match {
case _: InnerLike =>
case LeftOuter | LeftSemi | LeftAnti if gpuBuildSide == GpuBuildLeft =>
Expand All @@ -115,7 +121,9 @@ class GpuBroadcastNestedLoopJoinMeta(
joinExec
} else {
// condition cannot be implemented via AST so fallback to a post-filter if necessary
condition.map(c => GpuFilterExec(c, joinExec)).getOrElse(joinExec)
condition.map {
c => GpuFilterExec(c, joinExec, coalesceAfter = false)
}.getOrElse(joinExec)
}
}
}
Expand Down