Skip to content

Commit 51a9e5d

Browse files
committed
[SPARK-7927] whitespace fixes for Catalyst module.
1 parent 3e312a5 commit 51a9e5d

File tree

20 files changed

+73
-82
lines changed

20 files changed

+73
-82
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/AbstractSparkSQLParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class SqlLexical extends StdLexical {
103103
( identChar ~ (identChar | digit).* ^^
104104
{ case first ~ rest => processIdent((first :: rest).mkString) }
105105
| rep1(digit) ~ ('.' ~> digit.*).? ^^ {
106-
case i ~ None => NumericLit(i.mkString)
106+
case i ~ None => NumericLit(i.mkString)
107107
case i ~ Some(d) => FloatLit(i.mkString + "." + d.mkString)
108108
}
109109
| '\'' ~> chrExcept('\'', '\n', EofCh).* <~ '\'' ^^

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser {
140140
(HAVING ~> expression).? ~
141141
sortType.? ~
142142
(LIMIT ~> expression).? ^^ {
143-
case d ~ p ~ r ~ f ~ g ~ h ~ o ~ l =>
143+
case d ~ p ~ r ~ f ~ g ~ h ~ o ~ l =>
144144
val base = r.getOrElse(OneRowRelation)
145145
val withFilter = f.map(Filter(_, base)).getOrElse(base)
146146
val withProjection = g
@@ -212,7 +212,7 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser {
212212

213213
protected lazy val ordering: Parser[Seq[SortOrder]] =
214214
( rep1sep(expression ~ direction.? , ",") ^^ {
215-
case exps => exps.map(pair => SortOrder(pair._1, pair._2.getOrElse(Ascending)))
215+
case exps => exps.map(pair => SortOrder(pair._1, pair._2.getOrElse(Ascending)))
216216
}
217217
)
218218

@@ -242,7 +242,7 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser {
242242
| termExpression ~ NOT.? ~ (BETWEEN ~> termExpression) ~ (AND ~> termExpression) ^^ {
243243
case e ~ not ~ el ~ eu =>
244244
val betweenExpr: Expression = And(GreaterThanOrEqual(e, el), LessThanOrEqual(e, eu))
245-
not.fold(betweenExpr)(f=> Not(betweenExpr))
245+
not.fold(betweenExpr)(f => Not(betweenExpr))
246246
}
247247
| termExpression ~ (RLIKE ~> termExpression) ^^ { case e1 ~ e2 => RLike(e1, e2) }
248248
| termExpression ~ (REGEXP ~> termExpression) ^^ { case e1 ~ e2 => RLike(e1, e2) }
@@ -365,7 +365,7 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser {
365365

366366
protected lazy val baseExpression: Parser[Expression] =
367367
( "*" ^^^ UnresolvedStar(None)
368-
| ident <~ "." ~ "*" ^^ { case tableName => UnresolvedStar(Option(tableName)) }
368+
| ident <~ "." ~ "*" ^^ { case tableName => UnresolvedStar(Option(tableName)) }
369369
| primary
370370
)
371371

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class Analyzer(
494494
def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {
495495
case filter @ Filter(havingCondition, aggregate @ Aggregate(_, originalAggExprs, _))
496496
if aggregate.resolved && containsAggregate(havingCondition) => {
497-
val evaluatedCondition = Alias(havingCondition, "havingCondition")()
497+
val evaluatedCondition = Alias(havingCondition, "havingCondition")()
498498
val aggExprsWithHaving = evaluatedCondition +: originalAggExprs
499499

500500
Project(aggregate.output,
@@ -515,16 +515,15 @@ class Analyzer(
515515
* - concrete attribute references for their output.
516516
* - to be relocated from a SELECT clause (i.e. from a [[Project]]) into a [[Generate]]).
517517
*
518-
* Names for the output [[Attributes]] are extracted from [[Alias]] or [[MultiAlias]] expressions
518+
* Names for the output [[Attribute]]s are extracted from [[Alias]] or [[MultiAlias]] expressions
519519
* that wrap the [[Generator]]. If more than one [[Generator]] is found in a Project, an
520520
* [[AnalysisException]] is throw.
521521
*/
522522
object ResolveGenerate extends Rule[LogicalPlan] {
523523
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
524524
case p: Generate if !p.child.resolved || !p.generator.resolved => p
525-
case g: Generate if g.resolved == false =>
526-
g.copy(
527-
generatorOutput = makeGeneratorOutput(g.generator, g.generatorOutput.map(_.name)))
525+
case g: Generate if !g.resolved =>
526+
g.copy(generatorOutput = makeGeneratorOutput(g.generator, g.generatorOutput.map(_.name)))
528527

529528
case p @ Project(projectList, child) =>
530529
// Holds the resolved generator, if one exists in the project list.

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Catalog.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class SimpleCatalog(val conf: CatalystConf) extends Catalog {
140140
trait OverrideCatalog extends Catalog {
141141

142142
// TODO: This doesn't work when the database changes...
143-
val overrides = new mutable.HashMap[(Option[String],String), LogicalPlan]()
143+
val overrides = new mutable.HashMap[(Option[String], String), LogicalPlan]()
144144

145145
abstract override def tableExists(tableIdentifier: Seq[String]): Boolean = {
146146
val tableIdent = processTableIdentifier(tableIdentifier)

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,7 @@ trait HiveTypeCoercion {
561561

562562
case a @ CreateArray(children) if !a.resolved =>
563563
val commonType = a.childTypes.reduce(
564-
(a,b) =>
565-
findTightestCommonType(a,b).getOrElse(StringType))
564+
(a, b) => findTightestCommonType(a, b).getOrElse(StringType))
566565
CreateArray(
567566
children.map(c => if (c.dataType == commonType) c else Cast(c, commonType)))
568567

@@ -634,7 +633,7 @@ trait HiveTypeCoercion {
634633
import HiveTypeCoercion._
635634

636635
def apply(plan: LogicalPlan): LogicalPlan = plan transformAllExpressions {
637-
case cw: CaseWhenLike if !cw.resolved && cw.childrenResolved && !cw.valueTypesEqual =>
636+
case cw: CaseWhenLike if !cw.resolved && cw.childrenResolved && !cw.valueTypesEqual =>
638637
logDebug(s"Input values for null casting ${cw.valueTypes.mkString(",")}")
639638
val commonType = cw.valueTypes.reduce { (v1, v2) =>
640639
findTightestCommonType(v1, v2).getOrElse(sys.error(

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/dsl/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ package object dsl {
140140
// Note that if we make ExpressionConversions an object rather than a trait, we can
141141
// then make this a value class to avoid the small penalty of runtime instantiation.
142142
def $(args: Any*): analysis.UnresolvedAttribute = {
143-
analysis.UnresolvedAttribute(sc.s(args :_*))
143+
analysis.UnresolvedAttribute(sc.s(args : _*))
144144
}
145145
}
146146

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/errors/package.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,4 @@ package object errors {
4949
case e: Exception => throw new TreeNodeException(tree, msg, e)
5050
}
5151
}
52-
53-
/**
54-
* Executes `f` which is expected to throw a
55-
* [[catalyst.errors.TreeNodeException TreeNodeException]]. The first tree encountered in
56-
* the stack of exceptions of type `TreeType` is returned.
57-
*/
58-
def getTree[TreeType <: TreeNode[_]](f: => Unit): TreeType = ??? // TODO: Implement
5952
}

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

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,48 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
3535

3636
private[this] def forceNullable(from: DataType, to: DataType) = (from, to) match {
3737
case (StringType, _: NumericType) => true
38-
case (StringType, TimestampType) => true
39-
case (DoubleType, TimestampType) => true
40-
case (FloatType, TimestampType) => true
41-
case (StringType, DateType) => true
42-
case (_: NumericType, DateType) => true
43-
case (BooleanType, DateType) => true
44-
case (DateType, _: NumericType) => true
45-
case (DateType, BooleanType) => true
38+
case (StringType, TimestampType) => true
39+
case (DoubleType, TimestampType) => true
40+
case (FloatType, TimestampType) => true
41+
case (StringType, DateType) => true
42+
case (_: NumericType, DateType) => true
43+
case (BooleanType, DateType) => true
44+
case (DateType, _: NumericType) => true
45+
case (DateType, BooleanType) => true
4646
case (DoubleType, _: DecimalType) => true
47-
case (FloatType, _: DecimalType) => true
47+
case (FloatType, _: DecimalType) => true
4848
case (_, DecimalType.Fixed(_, _)) => true // TODO: not all upcasts here can really give null
49-
case _ => false
49+
case _ => false
5050
}
5151

5252
private[this] def resolvableNullability(from: Boolean, to: Boolean) = !from || to
5353

5454
private[this] def resolve(from: DataType, to: DataType): Boolean = {
5555
(from, to) match {
56-
case (from, to) if from == to => true
56+
case (from, to) if from == to => true
5757

58-
case (NullType, _) => true
58+
case (NullType, _) => true
5959

60-
case (_, StringType) => true
60+
case (_, StringType) => true
6161

62-
case (StringType, BinaryType) => true
62+
case (StringType, BinaryType) => true
6363

64-
case (StringType, BooleanType) => true
65-
case (DateType, BooleanType) => true
66-
case (TimestampType, BooleanType) => true
67-
case (_: NumericType, BooleanType) => true
64+
case (StringType, BooleanType) => true
65+
case (DateType, BooleanType) => true
66+
case (TimestampType, BooleanType) => true
67+
case (_: NumericType, BooleanType) => true
6868

69-
case (StringType, TimestampType) => true
70-
case (BooleanType, TimestampType) => true
71-
case (DateType, TimestampType) => true
72-
case (_: NumericType, TimestampType) => true
69+
case (StringType, TimestampType) => true
70+
case (BooleanType, TimestampType) => true
71+
case (DateType, TimestampType) => true
72+
case (_: NumericType, TimestampType) => true
7373

74-
case (_, DateType) => true
74+
case (_, DateType) => true
7575

76-
case (StringType, _: NumericType) => true
77-
case (BooleanType, _: NumericType) => true
78-
case (DateType, _: NumericType) => true
79-
case (TimestampType, _: NumericType) => true
76+
case (StringType, _: NumericType) => true
77+
case (BooleanType, _: NumericType) => true
78+
case (DateType, _: NumericType) => true
79+
case (TimestampType, _: NumericType) => true
8080
case (_: NumericType, _: NumericType) => true
8181

8282
case (ArrayType(from, fn), ArrayType(to, tn)) =>
@@ -410,21 +410,21 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
410410

411411
private[this] def cast(from: DataType, to: DataType): Any => Any = to match {
412412
case dt if dt == child.dataType => identity[Any]
413-
case StringType => castToString(from)
414-
case BinaryType => castToBinary(from)
415-
case DateType => castToDate(from)
416-
case decimal: DecimalType => castToDecimal(from, decimal)
417-
case TimestampType => castToTimestamp(from)
418-
case BooleanType => castToBoolean(from)
419-
case ByteType => castToByte(from)
420-
case ShortType => castToShort(from)
421-
case IntegerType => castToInt(from)
422-
case FloatType => castToFloat(from)
423-
case LongType => castToLong(from)
424-
case DoubleType => castToDouble(from)
425-
case array: ArrayType => castArray(from.asInstanceOf[ArrayType], array)
426-
case map: MapType => castMap(from.asInstanceOf[MapType], map)
427-
case struct: StructType => castStruct(from.asInstanceOf[StructType], struct)
413+
case StringType => castToString(from)
414+
case BinaryType => castToBinary(from)
415+
case DateType => castToDate(from)
416+
case decimal: DecimalType => castToDecimal(from, decimal)
417+
case TimestampType => castToTimestamp(from)
418+
case BooleanType => castToBoolean(from)
419+
case ByteType => castToByte(from)
420+
case ShortType => castToShort(from)
421+
case IntegerType => castToInt(from)
422+
case FloatType => castToFloat(from)
423+
case LongType => castToLong(from)
424+
case DoubleType => castToDouble(from)
425+
case array: ArrayType => castArray(from.asInstanceOf[ArrayType], array)
426+
case map: MapType => castMap(from.asInstanceOf[MapType], map)
427+
case struct: StructType => castStruct(from.asInstanceOf[StructType], struct)
428428
}
429429

430430
private[this] lazy val cast: Any => Any = cast(child.dataType, dataType)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object ExtractValue {
4747
case (ArrayType(StructType(fields), containsNull), Literal(fieldName, StringType)) =>
4848
val ordinal = findField(fields, fieldName.toString, resolver)
4949
GetArrayStructFields(child, fields(ordinal), ordinal, containsNull)
50-
case (_: ArrayType, _) if extraction.dataType.isInstanceOf[IntegralType] =>
50+
case (_: ArrayType, _) if extraction.dataType.isInstanceOf[IntegralType] =>
5151
GetArrayItem(child, extraction)
5252
case (_: MapType, _) =>
5353
GetMapValue(child, extraction)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ case class MinFunction(expr: Expression, base: AggregateExpression) extends Aggr
111111
override def update(input: Row): Unit = {
112112
if (currentMin.value == null) {
113113
currentMin.value = expr.eval(input)
114-
} else if(cmp.eval(input) == true) {
114+
} else if (cmp.eval(input) == true) {
115115
currentMin.value = expr.eval(input)
116116
}
117117
}
@@ -142,7 +142,7 @@ case class MaxFunction(expr: Expression, base: AggregateExpression) extends Aggr
142142
override def update(input: Row): Unit = {
143143
if (currentMax.value == null) {
144144
currentMax.value = expr.eval(input)
145-
} else if(cmp.eval(input) == true) {
145+
} else if (cmp.eval(input) == true) {
146146
currentMax.value = expr.eval(input)
147147
}
148148
}

0 commit comments

Comments
 (0)