diff options
author | Dongjoon Hyun <dongjoon@apache.org> | 2016-03-10 15:57:22 -0800 |
---|---|---|
committer | Andrew Or <andrew@databricks.com> | 2016-03-10 15:57:22 -0800 |
commit | 91fed8e9c57764eca9463d129ecd68196db7f566 (patch) | |
tree | b06c678dc15258af92116019760e6b9c98d81c2d /sql/catalyst | |
parent | 81d48532d954a8aea28d7e1fb3aa32a78c708b63 (diff) | |
download | spark-91fed8e9c57764eca9463d129ecd68196db7f566.tar.gz spark-91fed8e9c57764eca9463d129ecd68196db7f566.tar.bz2 spark-91fed8e9c57764eca9463d129ecd68196db7f566.zip |
[SPARK-3854][BUILD] Scala style: require spaces before `{`.
## What changes were proposed in this pull request?
Since the opening curly brace, '{', has many usages as discussed in [SPARK-3854](https://issues.apache.org/jira/browse/SPARK-3854), this PR adds a ScalaStyle rule to prevent '){' pattern for the following majority pattern and fixes the code accordingly. If we enforce this in ScalaStyle from now, it will improve the Scala code quality and reduce review time.
```
// Correct:
if (true) {
println("Wow!")
}
// Incorrect:
if (true){
println("Wow!")
}
```
IntelliJ also shows new warnings based on this.
## How was this patch tested?
Pass the Jenkins ScalaStyle test.
Author: Dongjoon Hyun <dongjoon@apache.org>
Closes #11637 from dongjoon-hyun/SPARK-3854.
Diffstat (limited to 'sql/catalyst')
4 files changed, 7 insertions, 7 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala index 87e43429e6..efd75295b2 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala @@ -159,7 +159,7 @@ case class CreateNamedStruct(children: Seq[Expression]) extends Expression { TypeCheckResult.TypeCheckFailure( s"Only foldable StringType expressions are allowed to appear at odd position , got :" + s" ${invalidNames.mkString(",")}") - } else if (!names.contains(null)){ + } else if (!names.contains(null)) { TypeCheckResult.TypeCheckSuccess } else { TypeCheckResult.TypeCheckFailure("Field name should not be null") diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala index bc2df0fb4a..12fcc40376 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala @@ -806,14 +806,14 @@ case class Round(child: Expression, scale: Expression) case FloatType => // if child eval to NaN or Infinity, just return it. if (_scale == 0) { s""" - if (Float.isNaN(${ce.value}) || Float.isInfinite(${ce.value})){ + if (Float.isNaN(${ce.value}) || Float.isInfinite(${ce.value})) { ${ev.value} = ${ce.value}; } else { ${ev.value} = Math.round(${ce.value}); }""" } else { s""" - if (Float.isNaN(${ce.value}) || Float.isInfinite(${ce.value})){ + if (Float.isNaN(${ce.value}) || Float.isInfinite(${ce.value})) { ${ev.value} = ${ce.value}; } else { ${ev.value} = java.math.BigDecimal.valueOf(${ce.value}). @@ -823,14 +823,14 @@ case class Round(child: Expression, scale: Expression) case DoubleType => // if child eval to NaN or Infinity, just return it. if (_scale == 0) { s""" - if (Double.isNaN(${ce.value}) || Double.isInfinite(${ce.value})){ + if (Double.isNaN(${ce.value}) || Double.isInfinite(${ce.value})) { ${ev.value} = ${ce.value}; } else { ${ev.value} = Math.round(${ce.value}); }""" } else { s""" - if (Double.isNaN(${ce.value}) || Double.isInfinite(${ce.value})){ + if (Double.isNaN(${ce.value}) || Double.isInfinite(${ce.value})) { ${ev.value} = ${ce.value}; } else { ${ev.value} = java.math.BigDecimal.valueOf(${ce.value}). diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/RowTest.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/RowTest.scala index 1e7118144f..d9577dea1b 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/RowTest.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/RowTest.scala @@ -86,7 +86,7 @@ class RowTest extends FunSpec with Matchers { } } - it("getAs() on type extending AnyVal does not throw exception when value is null"){ + it("getAs() on type extending AnyVal does not throw exception when value is null") { sampleRowWithoutCol3.getAs[String](sampleRowWithoutCol3.fieldIndex("col1")) shouldBe null } } diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala index 97a0cde381..a636d63012 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala @@ -535,7 +535,7 @@ class FilterPushdownSuite extends PlanTest { // Filter("c" > 6) assertResult(classOf[Filter])(optimized.getClass) assertResult(1)(optimized.asInstanceOf[Filter].condition.references.size) - assertResult("c"){ + assertResult("c") { optimized.asInstanceOf[Filter].condition.references.toSeq(0).name } |