Skip to content

Commit e35672e

Browse files
committed
[SQL] Minor cleanup of comments, errors and override.
Author: Michael Armbrust <[email protected]> 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 f805025) Signed-off-by: Michael Armbrust <[email protected]>
1 parent 576688a commit e35672e

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN
304304

305305
child.dataType match {
306306
case DecimalType.Fixed(_, _) =>
307-
// Turn the results to unlimited decimals for the divsion, before going back to fixed
307+
// Turn the results to unlimited decimals for the division, before going back to fixed
308308
val castedSum = Cast(Sum(partialSum.toAttribute), DecimalType.Unlimited)
309309
val castedCount = Cast(Sum(partialCount.toAttribute), DecimalType.Unlimited)
310310
SplitEvaluation(

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] {
5353
val nullFunctions =
5454
q"""
5555
private[this] var nullBits = new Array[Boolean](${expressions.size})
56-
final def setNullAt(i: Int) = { nullBits(i) = true }
57-
final def isNullAt(i: Int) = nullBits(i)
56+
override def setNullAt(i: Int) = { nullBits(i) = true }
57+
override def isNullAt(i: Int) = nullBits(i)
5858
""".children
5959

6060
val tupleElements = expressions.zipWithIndex.flatMap {
@@ -82,7 +82,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] {
8282
val iLit = ru.Literal(Constant(i))
8383
q"if(isNullAt($iLit)) { null } else { ${newTermName(s"c$i")} }"
8484
}
85-
q"final def iterator = Iterator[Any](..$allColumns)"
85+
q"override def iterator = Iterator[Any](..$allColumns)"
8686
}
8787

8888
val accessorFailure = q"""scala.sys.error("Invalid ordinal:" + i)"""
@@ -94,7 +94,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] {
9494

9595
q"if(i == $ordinal) { if(isNullAt($i)) return null else return $elementName }"
9696
}
97-
q"final def apply(i: Int): Any = { ..$cases; $accessorFailure }"
97+
q"override def apply(i: Int): Any = { ..$cases; $accessorFailure }"
9898
}
9999

100100
val updateFunction = {
@@ -114,7 +114,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] {
114114
return
115115
}"""
116116
}
117-
q"final def update(i: Int, value: Any): Unit = { ..$cases; $accessorFailure }"
117+
q"override def update(i: Int, value: Any): Unit = { ..$cases; $accessorFailure }"
118118
}
119119

120120
val specificAccessorFunctions = NativeType.all.map { dataType =>
@@ -128,7 +128,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] {
128128
}
129129

130130
q"""
131-
final def ${accessorForType(dataType)}(i: Int):${termForType(dataType)} = {
131+
override def ${accessorForType(dataType)}(i: Int):${termForType(dataType)} = {
132132
..$ifStatements;
133133
$accessorFailure
134134
}"""
@@ -145,7 +145,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] {
145145
}
146146

147147
q"""
148-
final def ${mutatorForType(dataType)}(i: Int, value: ${termForType(dataType)}): Unit = {
148+
override def ${mutatorForType(dataType)}(i: Int, value: ${termForType(dataType)}): Unit = {
149149
..$ifStatements;
150150
$accessorFailure
151151
}"""
@@ -193,7 +193,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] {
193193

194194
val copyFunction =
195195
q"""
196-
final def copy() = new $genericRowType(this.toArray)
196+
override def copy() = new $genericRowType(this.toArray)
197197
"""
198198

199199
val classBody =

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ case class Coalesce(children: Seq[Expression]) extends Expression {
3737
def dataType = if (resolved) {
3838
children.head.dataType
3939
} else {
40-
throw new UnresolvedException(this, "Coalesce cannot have children of different types.")
40+
val childTypes = children.map(c => s"$c: ${c.dataType}").mkString(", ")
41+
throw new UnresolvedException(
42+
this, s"Coalesce cannot have children of different types. $childTypes")
4143
}
4244

4345
override def eval(input: Row): Any = {

0 commit comments

Comments
 (0)