Parse an ORDER BY sub-expression optionally followed by ASC or DESC.
(&mut self)
| 900 | |
| 901 | /// Parse an ORDER BY sub-expression optionally followed by ASC or DESC. |
| 902 | pub fn parse_order_by_expr(&mut self) -> Result<OrderByExpr, DataFusionError> { |
| 903 | let expr = self.parser.parse_expr()?; |
| 904 | |
| 905 | let asc = if self.parser.parse_keyword(Keyword::ASC) { |
| 906 | Some(true) |
| 907 | } else if self.parser.parse_keyword(Keyword::DESC) { |
| 908 | Some(false) |
| 909 | } else { |
| 910 | None |
| 911 | }; |
| 912 | |
| 913 | let nulls_first = if self |
| 914 | .parser |
| 915 | .parse_keywords(&[Keyword::NULLS, Keyword::FIRST]) |
| 916 | { |
| 917 | Some(true) |
| 918 | } else if self.parser.parse_keywords(&[Keyword::NULLS, Keyword::LAST]) { |
| 919 | Some(false) |
| 920 | } else { |
| 921 | None |
| 922 | }; |
| 923 | |
| 924 | Ok(OrderByExpr { |
| 925 | expr, |
| 926 | options: OrderByOptions { asc, nulls_first }, |
| 927 | with_fill: None, |
| 928 | }) |
| 929 | } |
| 930 | |
| 931 | // This is a copy of the equivalent implementation in sqlparser. |
| 932 | fn parse_columns( |
no test coverage detected