Skip to content

Commit

Permalink
fix order, using asc by default
Browse files Browse the repository at this point in the history
  • Loading branch information
scwf committed Dec 30, 2014
1 parent 343db39 commit 48145d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,8 @@ class SqlParser extends AbstractSparkSQLParser {
)

protected lazy val ordering: Parser[Seq[SortOrder]] =
( rep1sep(singleOrder, ",")
| rep1sep(expression, ",") ~ direction.? ^^ {
case exps ~ d => exps.map(SortOrder(_, d.getOrElse(Ascending)))
( 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 @@ -987,6 +987,13 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
)
}

test("oder by asc by default when not specify ascending and descending") {
checkAnswer(
sql("SELECT a, b FROM testData2 ORDER BY a desc, b"),
Seq((3, 1), (3, 2), (2, 1), (2,2), (1, 1), (1, 2))
)
}

test("Supporting relational operator '<=>' in Spark SQL") {
val nullCheckData1 = TestData(1,"1") :: TestData(2,null) :: Nil
val rdd1 = sparkContext.parallelize((0 to 1).map(i => nullCheckData1(i)))
Expand Down

0 comments on commit 48145d3

Please sign in to comment.