Skip to content

Commit

Permalink
Code review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Feb 11, 2015
1 parent 015c4fc commit 87ff763
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sql/core/src/main/scala/org/apache/spark/sql/Column.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ trait Column extends DataFrame {
}

private def computableCol(baseCol: ComputableColumn, expr: Expression) = {
val plan = Project(Seq(expr match {
val namedExpr = expr match {
case named: NamedExpression => named
case unnamed: Expression => Alias(unnamed, "col")()
}), stripProject(baseCol.plan))
}
val plan = Project(Seq(namedExpr), stripProject(baseCol.plan))
Column(baseCol.sqlContext, plan, expr)
}

Expand All @@ -101,6 +102,8 @@ trait Column extends DataFrame {
if (stripProject(left.plan).sameResult(stripProject(right.plan))) {
computableCol(right, newExpr(right))
} else {
// We don't want to throw an exception here because "df1("a") === df2("b")" can be
// a valid expression for join conditions, even though standalone they are not valid.
Column(newExpr(right))
}
case (left: ComputableColumn, right) => computableCol(left, newExpr(right))
Expand Down

0 comments on commit 87ff763

Please sign in to comment.