diff options
author | Michael Armbrust <michael@databricks.com> | 2014-11-14 15:00:42 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2014-11-14 15:00:51 -0800 |
commit | e35672e7edeb7f68bece12d3d656419d3e610e95 (patch) | |
tree | 344a3dd449fa3e5a8eec82d64652b0046b401371 /sql/catalyst | |
parent | 576688aa2a19bd4ba239a2b93af7947f983e5124 (diff) | |
download | spark-e35672e7edeb7f68bece12d3d656419d3e610e95.tar.gz spark-e35672e7edeb7f68bece12d3d656419d3e610e95.tar.bz2 spark-e35672e7edeb7f68bece12d3d656419d3e610e95.zip |
[SQL] Minor cleanup of comments, errors and override.
Author: Michael Armbrust <michael@databricks.com>
Closes #3257 from marmbrus/minorCleanup and squashes the following commits:
d8b5abc [Michael Armbrust] Use interpolation.
2fdf903 [Michael Armbrust] Better error message when coalesce can't be resolved.
f9fa6cf [Michael Armbrust] Methods in a final class do not also need to be final, use override.
199fd98 [Michael Armbrust] Fix typo
(cherry picked from commit f805025e8efe9cd522e8875141ec27df8d16bbe0)
Signed-off-by: Michael Armbrust <michael@databricks.com>
Diffstat (limited to 'sql/catalyst')
3 files changed, 12 insertions, 10 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala index 2b364fc1df..3ceb5ecaf6 100755 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala @@ -304,7 +304,7 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN child.dataType match { case DecimalType.Fixed(_, _) => - // Turn the results to unlimited decimals for the divsion, before going back to fixed + // Turn the results to unlimited decimals for the division, before going back to fixed val castedSum = Cast(Sum(partialSum.toAttribute), DecimalType.Unlimited) val castedCount = Cast(Sum(partialCount.toAttribute), DecimalType.Unlimited) SplitEvaluation( diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala index 7871a62620..2ff61169a1 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala @@ -53,8 +53,8 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { val nullFunctions = q""" private[this] var nullBits = new Array[Boolean](${expressions.size}) - final def setNullAt(i: Int) = { nullBits(i) = true } - final def isNullAt(i: Int) = nullBits(i) + override def setNullAt(i: Int) = { nullBits(i) = true } + override def isNullAt(i: Int) = nullBits(i) """.children val tupleElements = expressions.zipWithIndex.flatMap { @@ -82,7 +82,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { val iLit = ru.Literal(Constant(i)) q"if(isNullAt($iLit)) { null } else { ${newTermName(s"c$i")} }" } - q"final def iterator = Iterator[Any](..$allColumns)" + q"override def iterator = Iterator[Any](..$allColumns)" } val accessorFailure = q"""scala.sys.error("Invalid ordinal:" + i)""" @@ -94,7 +94,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { q"if(i == $ordinal) { if(isNullAt($i)) return null else return $elementName }" } - q"final def apply(i: Int): Any = { ..$cases; $accessorFailure }" + q"override def apply(i: Int): Any = { ..$cases; $accessorFailure }" } val updateFunction = { @@ -114,7 +114,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { return }""" } - q"final def update(i: Int, value: Any): Unit = { ..$cases; $accessorFailure }" + q"override def update(i: Int, value: Any): Unit = { ..$cases; $accessorFailure }" } val specificAccessorFunctions = NativeType.all.map { dataType => @@ -128,7 +128,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { } q""" - final def ${accessorForType(dataType)}(i: Int):${termForType(dataType)} = { + override def ${accessorForType(dataType)}(i: Int):${termForType(dataType)} = { ..$ifStatements; $accessorFailure }""" @@ -145,7 +145,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { } q""" - final def ${mutatorForType(dataType)}(i: Int, value: ${termForType(dataType)}): Unit = { + override def ${mutatorForType(dataType)}(i: Int, value: ${termForType(dataType)}): Unit = { ..$ifStatements; $accessorFailure }""" @@ -193,7 +193,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { val copyFunction = q""" - final def copy() = new $genericRowType(this.toArray) + override def copy() = new $genericRowType(this.toArray) """ val classBody = diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala index 086d0a3e07..84a3567895 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala @@ -37,7 +37,9 @@ case class Coalesce(children: Seq[Expression]) extends Expression { def dataType = if (resolved) { children.head.dataType } else { - throw new UnresolvedException(this, "Coalesce cannot have children of different types.") + val childTypes = children.map(c => s"$c: ${c.dataType}").mkString(", ") + throw new UnresolvedException( + this, s"Coalesce cannot have children of different types. $childTypes") } override def eval(input: Row): Any = { |