Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,11 @@ 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)))
}
)

protected lazy val singleOrder: Parser[SortOrder] =
expression ~ direction ^^ { case e ~ o => SortOrder(e, o) }

protected lazy val direction: Parser[SortDirection] =
( ASC ^^^ Ascending
| DESC ^^^ Descending
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