Skip to content

Commit

Permalink
[SPARK-12692][BUILD][SQL] Scala style: Fix the style violation (Space…
Browse files Browse the repository at this point in the history
… before ",")

Fix the style violation (space before , and :).
This PR is a followup for #10643 and rework of #10685 .

Author: Kousuke Saruta <[email protected]>

Closes #10732 from sarutak/SPARK-12692-followup-sql.
  • Loading branch information
sarutak authored and rxin committed Jan 13, 2016
1 parent dc7b387 commit cb7b864
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ object SqlParser extends AbstractSparkSQLParser with DataTypeParser {
)

protected lazy val ordering: Parser[Seq[SortOrder]] =
( rep1sep(expression ~ direction.? , ",") ^^ {
( rep1sep(expression ~ direction.?, ",") ^^ {
case exps => exps.map(pair => SortOrder(pair._1, pair._2.getOrElse(Ascending)))
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ object NumberConverter {
* unsigned, otherwise it is signed.
* NB: This logic is borrowed from org.apache.hadoop.hive.ql.ud.UDFConv
*/
def convert(n: Array[Byte] , fromBase: Int, toBase: Int ): UTF8String = {
def convert(n: Array[Byte], fromBase: Int, toBase: Int ): UTF8String = {
if (fromBase < Character.MIN_RADIX || fromBase > Character.MAX_RADIX
|| Math.abs(toBase) < Character.MIN_RADIX
|| Math.abs(toBase) > Character.MAX_RADIX) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class BooleanSimplificationSuite extends PlanTest with PredicateHelper {

checkCondition(('a < 2 || 'a > 3 || 'b > 5) && 'a < 2, 'a < 2)

checkCondition('a < 2 && ('a < 2 || 'a > 3 || 'b > 5) , 'a < 2)
checkCondition('a < 2 && ('a < 2 || 'a > 3 || 'b > 5), 'a < 2)

checkCondition(('a < 2 || 'b > 3) && ('a < 2 || 'c > 5), 'a < 2 || ('b > 3 && 'c > 5))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ class SQLContext private[sql](
}
}

// Register a succesfully instantiatd context to the singleton. This should be at the end of
// Register a successfully instantiated context to the singleton. This should be at the end of
// the class definition so that the singleton is updated only if there is no exception in the
// construction of the instance.
sparkContext.addSparkListener(new SparkListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ case class Exchange(
new ShuffledRowRDD(shuffleDependency, specifiedPartitionStartIndices)
}

protected override def doExecute(): RDD[InternalRow] = attachTree(this , "execute") {
protected override def doExecute(): RDD[InternalRow] = attachTree(this, "execute") {
coordinator match {
case Some(exchangeCoordinator) =>
val shuffleRDD = exchangeCoordinator.postShuffleRDD(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DatasetCacheSuite extends QueryTest with SharedSQLContext {
import testImplicits._

test("persist and unpersist") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS().select(expr("_2 + 1").as[Int])
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS().select(expr("_2 + 1").as[Int])
val cached = ds.cache()
// count triggers the caching action. It should not throw.
cached.count()
Expand Down
24 changes: 12 additions & 12 deletions sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
import testImplicits._

test("toDS") {
val data = Seq(("a", 1) , ("b", 2), ("c", 3))
val data = Seq(("a", 1), ("b", 2), ("c", 3))
checkAnswer(
data.toDS(),
data: _*)
Expand Down Expand Up @@ -87,7 +87,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}

test("as case class / collect") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDF("a", "b").as[ClassData]
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDF("a", "b").as[ClassData]
checkAnswer(
ds,
ClassData("a", 1), ClassData("b", 2), ClassData("c", 3))
Expand All @@ -105,7 +105,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}

test("map") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
checkAnswer(
ds.map(v => (v._1, v._2 + 1)),
("a", 2), ("b", 3), ("c", 4))
Expand All @@ -124,14 +124,14 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}

test("select") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
checkAnswer(
ds.select(expr("_2 + 1").as[Int]),
2, 3, 4)
}

test("select 2") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
checkAnswer(
ds.select(
expr("_1").as[String],
Expand All @@ -140,7 +140,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}

test("select 2, primitive and tuple") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
checkAnswer(
ds.select(
expr("_1").as[String],
Expand All @@ -149,7 +149,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}

test("select 2, primitive and class") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
checkAnswer(
ds.select(
expr("_1").as[String],
Expand All @@ -158,7 +158,7 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}

test("select 2, primitive and class, fields reordered") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
checkDecoding(
ds.select(
expr("_1").as[String],
Expand All @@ -167,28 +167,28 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}

test("filter") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
checkAnswer(
ds.filter(_._1 == "b"),
("b", 2))
}

test("foreach") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
val acc = sparkContext.accumulator(0)
ds.foreach(v => acc += v._2)
assert(acc.value == 6)
}

test("foreachPartition") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
val acc = sparkContext.accumulator(0)
ds.foreachPartition(_.foreach(v => acc += v._2))
assert(acc.value == 6)
}

test("reduce") {
val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS()
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
assert(ds.reduce((a, b) => ("sum", a._2 + b._2)) == ("sum", 6))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class JsonSuite extends QueryTest with SharedSQLContext with TestJsonData {
StructType(
StructField("f1", IntegerType, true) ::
StructField("f2", IntegerType, true) :: Nil),
StructType(StructField("f1", LongType, true) :: Nil) ,
StructType(StructField("f1", LongType, true) :: Nil),
StructType(
StructField("f1", LongType, true) ::
StructField("f2", IntegerType, true) :: Nil))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
if (counter != 0) {
responseMsg += s", Fetched $counter row(s)"
}
console.printInfo(responseMsg , null)
console.printInfo(responseMsg, null)
// Destroy the driver to release all the locks.
driver.destroy()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ class InsertIntoHiveTableSuite extends QueryTest with TestHiveSingleton with Bef
}
val expected = List(
"p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=2"::Nil,
"p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=3"::Nil ,
"p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=1"::Nil ,
"p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=3"::Nil,
"p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=1"::Nil,
"p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=4"::Nil
)
assert(listFolders(tmpDir, List()).sortBy(_.toString()) === expected.sortBy(_.toString))
Expand Down

0 comments on commit cb7b864

Please sign in to comment.