MCPcopy Create free account
hub / github.com/apache/datafusion / parse_order_by_expr

Method parse_order_by_expr

datafusion/sql/src/parser.rs:902–929  ·  view source on GitHub ↗

Parse an ORDER BY sub-expression optionally followed by ASC or DESC.

(&mut self)

Source from the content-addressed store, hash-verified

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(

Callers 1

parse_order_by_exprsMethod · 0.80

Calls 1

parse_exprMethod · 0.80

Tested by

no test coverage detected