Skip to content

Commit e2b1ae3

Browse files
authored
feat: Hive: support SORT BY direction (#1873)
1 parent 4cf5e57 commit e2b1ae3

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/ast/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub struct Select {
341341
/// DISTRIBUTE BY (Hive)
342342
pub distribute_by: Vec<Expr>,
343343
/// SORT BY (Hive)
344-
pub sort_by: Vec<Expr>,
344+
pub sort_by: Vec<OrderByExpr>,
345345
/// HAVING
346346
pub having: Option<Expr>,
347347
/// WINDOW AS

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11591,7 +11591,7 @@ impl<'a> Parser<'a> {
1159111591
};
1159211592

1159311593
let sort_by = if self.parse_keywords(&[Keyword::SORT, Keyword::BY]) {
11594-
self.parse_comma_separated(Parser::parse_expr)?
11594+
self.parse_comma_separated(Parser::parse_order_by_expr)?
1159511595
} else {
1159611596
vec![]
1159711597
};

tests/sqlparser_hive.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ fn lateral_view() {
341341
fn sort_by() {
342342
let sort_by = "SELECT * FROM db.table SORT BY a";
343343
hive().verified_stmt(sort_by);
344+
345+
let sort_by_with_direction = "SELECT * FROM db.table SORT BY a, b DESC";
346+
hive().verified_stmt(sort_by_with_direction);
344347
}
345348

346349
#[test]

0 commit comments

Comments
 (0)