Skip to content
Closed
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
Prev Previous commit
Next Next commit
Revert previous attempt
  • Loading branch information
tedyu committed Mar 17, 2016
commit 302753b1a10caa55b4a18ccce87cab64bcf35e5f
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C

val relations = fromClause match {
case Some(f) => nodeToRelation(f)
case None => OneRowRelation()
case None => OneRowRelation
}

val withLateralView = lateralViewClause.map { lv =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ case class Repartition(numPartitions: Int, shuffle: Boolean, child: LogicalPlan)
/**
* A relation with one row. This is used in "SELECT ..." without a from clause.
*/
case class OneRowRelation() extends LeafNode {
case object OneRowRelation extends LeafNode {
override def maxRows: Option[Long] = Some(1)
override def output: Seq[Attribute] = Nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ trait ExpressionEvalHelper extends GeneratorDrivenPropertyChecks {
expression: Expression,
expected: Any,
inputRow: InternalRow = EmptyRow): Unit = {
val plan = Project(Alias(expression, s"Optimized($expression)")() :: Nil, OneRowRelation())
val plan = Project(Alias(expression, s"Optimized($expression)")() :: Nil, OneRowRelation)
val optimizedPlan = DefaultOptimizer.execute(plan)
checkEvaluationWithoutCodegen(optimizedPlan.expressions.head, expected, inputRow)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class MathFunctionsSuite extends SparkFunSuite with ExpressionEvalHelper {
private def checkNaNWithOptimization(
expression: Expression,
inputRow: InternalRow = EmptyRow): Unit = {
val plan = Project(Alias(expression, s"Optimized($expression)")() :: Nil, OneRowRelation())
val plan = Project(Alias(expression, s"Optimized($expression)")() :: Nil, OneRowRelation)
val optimizedPlan = DefaultOptimizer.execute(plan)
checkNaNWithoutCodegen(optimizedPlan.expressions.head, inputRow)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ColumnPruningSuite extends PlanTest {
}

test("Eliminate the Project with an empty projectList") {
val input = OneRowRelation()
val input = OneRowRelation
val expected = Project(Literal(1).as("1") :: Nil, input).analyze

val query1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class EliminateSubqueryAliasesSuite extends PlanTest with PredicateHelper {
}

private def assertEquivalent(e1: Expression, e2: Expression): Unit = {
val correctAnswer = Project(Alias(e2, "out")() :: Nil, OneRowRelation()).analyze
val actual = Optimize.execute(Project(Alias(e1, "out")() :: Nil, OneRowRelation()).analyze)
val correctAnswer = Project(Alias(e2, "out")() :: Nil, OneRowRelation).analyze
val actual = Optimize.execute(Project(Alias(e1, "out")() :: Nil, OneRowRelation).analyze)
comparePlans(actual, correctAnswer)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SimplifyConditionalSuite extends PlanTest with PredicateHelper {
}

protected def assertEquivalent(e1: Expression, e2: Expression): Unit = {
val correctAnswer = Project(Alias(e2, "out")() :: Nil, OneRowRelation()).analyze
val correctAnswer = Project(Alias(e2, "out")() :: Nil, OneRowRelation).analyze
val actual = Optimize.execute(Project(Alias(e1, "out")() :: Nil, OneRowRelation).analyze)
comparePlans(actual, correctAnswer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CatalystQlSuite extends PlanTest {
val parser = new CatalystQl()

test("test case insensitive") {
val result = Project(UnresolvedAlias(Literal(1)):: Nil, OneRowRelation())
val result = Project(UnresolvedAlias(Literal(1)):: Nil, OneRowRelation)
assert(result === parser.parsePlan("seLect 1"))
assert(result === parser.parsePlan("select 1"))
assert(result === parser.parsePlan("SELECT 1"))
Expand All @@ -42,7 +42,7 @@ class CatalystQlSuite extends PlanTest {
Not(
GreaterThan(Literal(true), Literal(true)))
) :: Nil,
OneRowRelation())
OneRowRelation)
comparePlans(parsed, expected)
}

Expand Down Expand Up @@ -82,7 +82,7 @@ class CatalystQlSuite extends PlanTest {
UnresolvedAlias(
Literal(result)
) :: Nil,
OneRowRelation())
OneRowRelation)
comparePlans(parsed, expected)
}

Expand Down Expand Up @@ -133,7 +133,7 @@ class CatalystQlSuite extends PlanTest {
UnresolvedAlias(
Literal(output)
) :: Nil,
OneRowRelation())
OneRowRelation)
comparePlans(parsed, expected)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ abstract class PlanTest extends SparkFunSuite with PredicateHelper {

/** Fails the test if the two expressions do not match */
protected def compareExpressions(e1: Expression, e2: Expression): Unit = {
comparePlans(Filter(e1, OneRowRelation()), Filter(e2, OneRowRelation()))
comparePlans(Filter(e1, OneRowRelation), Filter(e2, OneRowRelation))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,14 @@ class SQLBuilder(logicalPlan: LogicalPlan, sqlContext: SQLContext) extends Loggi
}

private def addSubqueryIfNeeded(plan: LogicalPlan): LogicalPlan = plan match {
case _: SubqueryAlias => plan
case _: Filter => plan
case _: Join => plan
case _: LocalLimit => plan
case _: GlobalLimit => plan
case _: SQLTable => plan
case _: Generate => plan
case _: OneRowRelation => plan
case _: SubqueryAlias |
_: Filter |
_: Join |
_: LocalLimit |
_: GlobalLimit |
_: SQLTable |
_: Generate |
OneRowRelation => plan
case _ => addSubquery(plan)
}
}
Expand Down