2020
2121use quickwit_proto:: sortschema:: { SortColumn , SortColumnDirection , SortSchema } ;
2222
23+ use super :: SortFieldsError ;
2324use super :: column_type:: { ColumnTypeId , default_is_descending} ;
2425use super :: validation:: validate_schema;
25- use super :: SortFieldsError ;
2626
2727/// The minimum sort version we accept. V0 (INCORRECT_TRIM) and V1 (TRIMMED_WITH_BUDGET)
2828/// are rejected per the strict V2-only decision.
@@ -80,7 +80,9 @@ pub fn parse_sort_fields(s: &str) -> Result<SortSchema, SortFieldsError> {
8080 3 => parse_3part ( parts, prefix_dir, col_str) ?,
8181 2 => parse_2part ( parts, prefix_dir, col_str) ?,
8282 1 => {
83- schema. column . push ( parse_1part ( parts[ 0 ] , prefix_dir, col_str) ?) ;
83+ schema
84+ . column
85+ . push ( parse_1part ( parts[ 0 ] , prefix_dir, col_str) ?) ;
8486 continue ;
8587 }
8688 _ => {
@@ -138,8 +140,8 @@ fn parse_cutoff_marker<'a>(
138140 let Some ( rest) = col_str. strip_prefix ( '&' ) else {
139141 if col_str. contains ( '&' ) {
140142 return Err ( SortFieldsError :: MalformedSchema ( format ! (
141- "LSM cutoff marker (&) must appear at the beginning of column name, \
142- found in middle of: {}",
143+ "LSM cutoff marker (&) must appear at the beginning of column name, found in \
144+ middle of: {}",
143145 col_str
144146 ) ) ) ;
145147 }
@@ -160,13 +162,15 @@ fn parse_cutoff_marker<'a>(
160162 }
161163 if column_index == 0 {
162164 return Err ( SortFieldsError :: InvalidCutoffPlacement (
163- "LSM cutoff marker (&) cannot be used on the first column as it would ignore all columns" . to_string ( ) ,
165+ "LSM cutoff marker (&) cannot be used on the first column as it would ignore all \
166+ columns"
167+ . to_string ( ) ,
164168 ) ) ;
165169 }
166170 if rest. contains ( '&' ) {
167171 return Err ( SortFieldsError :: MalformedSchema ( format ! (
168- "LSM cutoff marker (&) must appear at the beginning of column name, \
169- found in middle of: {}",
172+ "LSM cutoff marker (&) must appear at the beginning of column name, found in middle \
173+ of: {}",
170174 rest
171175 ) ) ) ;
172176 }
@@ -288,9 +292,15 @@ fn split_once_max2<'a>(
288292/// Strip a leading `+` or `-` from a string, returning the direction and remainder.
289293fn strip_direction_prefix ( s : & str ) -> ( Option < i32 > , & str ) {
290294 if let Some ( rest) = s. strip_prefix ( '+' ) {
291- ( Some ( SortColumnDirection :: SortDirectionAscending as i32 ) , rest)
295+ (
296+ Some ( SortColumnDirection :: SortDirectionAscending as i32 ) ,
297+ rest,
298+ )
292299 } else if let Some ( rest) = s. strip_prefix ( '-' ) {
293- ( Some ( SortColumnDirection :: SortDirectionDescending as i32 ) , rest)
300+ (
301+ Some ( SortColumnDirection :: SortDirectionDescending as i32 ) ,
302+ rest,
303+ )
294304 } else {
295305 ( None , s)
296306 }
@@ -300,10 +310,16 @@ fn strip_direction_prefix(s: &str) -> (Option<i32>, &str) {
300310fn strip_direction_suffix ( s : & str ) -> ( Option < i32 > , & str ) {
301311 if s. len ( ) > 1 {
302312 if let Some ( rest) = s. strip_suffix ( '+' ) {
303- return ( Some ( SortColumnDirection :: SortDirectionAscending as i32 ) , rest) ;
313+ return (
314+ Some ( SortColumnDirection :: SortDirectionAscending as i32 ) ,
315+ rest,
316+ ) ;
304317 }
305318 if let Some ( rest) = s. strip_suffix ( '-' ) {
306- return ( Some ( SortColumnDirection :: SortDirectionDescending as i32 ) , rest) ;
319+ return (
320+ Some ( SortColumnDirection :: SortDirectionDescending as i32 ) ,
321+ rest,
322+ ) ;
307323 }
308324 }
309325 ( None , s)
0 commit comments