(
tokens: &[Token],
position: &mut usize,
sorting_order: &SortingOrder,
)
| 107 | } |
| 108 | |
| 109 | fn parse_order_by_nulls_policy( |
| 110 | tokens: &[Token], |
| 111 | position: &mut usize, |
| 112 | sorting_order: &SortingOrder, |
| 113 | ) -> Result<NullsOrderPolicy, Box<Diagnostic>> { |
| 114 | // Check for `NULLs FIRST` or `NULLs LAST` |
| 115 | if is_current_token(tokens, position, TokenKind::Nulls) { |
| 116 | // Consume `NULLs` keyword |
| 117 | *position += 1; |
| 118 | |
| 119 | // Consume `FIRST` and return NUlls First policy |
| 120 | if is_current_token(tokens, position, TokenKind::First) { |
| 121 | *position += 1; |
| 122 | return Ok(NullsOrderPolicy::NullsFirst); |
| 123 | } |
| 124 | |
| 125 | // Consume `LAST` and return NUlls Last policy |
| 126 | if is_current_token(tokens, position, TokenKind::Last) { |
| 127 | *position += 1; |
| 128 | return Ok(NullsOrderPolicy::NullsLast); |
| 129 | } |
| 130 | |
| 131 | return Err(Diagnostic::error("Unexpected NULL ordering policy") |
| 132 | .add_note("Null ordering policy must be `FIRST` or `LAST`") |
| 133 | .add_help("Please use `NULL FIRST` or `NULL LAST`") |
| 134 | .with_location(tokens[*position].location) |
| 135 | .as_boxed()); |
| 136 | } |
| 137 | |
| 138 | let default_null_ordering_policy = match sorting_order { |
| 139 | SortingOrder::Ascending => NullsOrderPolicy::NullsLast, |
| 140 | SortingOrder::Descending => NullsOrderPolicy::NullsFirst, |
| 141 | }; |
| 142 | |
| 143 | Ok(default_null_ordering_policy) |
| 144 | } |
| 145 | |
| 146 | #[inline(always)] |
| 147 | fn is_order_by_using_operator(token: &Token) -> bool { |
no test coverage detected
searching dependent graphs…