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
fix bug
  • Loading branch information
Davies Liu committed Feb 25, 2016
commit ef9e8f3558b20f6a4a7c94eb7c46a8f435694ad4
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,14 @@ case class BroadcastHashJoin(
val numOutput = metricTerm(ctx, "numOutputRows")

val checkCondition = if (condition.isDefined) {
val expr = condition.get
// evaluate the variables from build side that used by condition
val eval = evaluateRequiredVariables(buildPlan.output, buildVars, expr.references)
// filter the output via condition
ctx.currentVars = input ++ buildVars
val ev = BindReferences.bindReference(
condition.get, streamedPlan.output ++ buildPlan.output).gen(ctx)
val ev = BindReferences.bindReference(expr, streamedPlan.output ++ buildPlan.output).gen(ctx)
s"""
|$eval
|${ev.code}
|if (${ev.isNull} || !${ev.value}) continue;
""".stripMargin
Expand Down Expand Up @@ -257,10 +260,11 @@ case class BroadcastHashJoin(
// filter the output via condition
val conditionPassed = ctx.freshName("conditionPassed")
val checkCondition = if (condition.isDefined) {
val eval = evaluateRequiredVariables(buildPlan.output, buildVars, condition.get.references)
val expr = condition.get
// evaluate the variables from build side that used by condition
val eval = evaluateRequiredVariables(buildPlan.output, buildVars, expr.references)
ctx.currentVars = input ++ buildVars
val ev = BindReferences.bindReference(condition.get,
streamedPlan.output ++ buildPlan.output).gen(ctx)
val ev = BindReferences.bindReference(expr, streamedPlan.output ++ buildPlan.output).gen(ctx)
s"""
|boolean $conditionPassed = true;
|${eval.trim}
Expand All @@ -285,7 +289,6 @@ case class BroadcastHashJoin(
|UnsafeRow $matched = $anyNull ? null: (UnsafeRow)$relationTerm.getValue(${keyEv.value});
|${checkCondition.trim}
|if (!$conditionPassed) {
| // reset to null
| $matched = null;
| // reset the variables those are already evaluated.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we find a row on build side, but the condition do not pass, the variables for build side still have the value (from build side), but the result should be empty (outer join).

| ${buildVars.filter(_.code == "").map(v => s"${v.isNull} = true;").mkString("\n")}
Expand Down