Skip to content

Commit 70a48be

Browse files
committed
style: rustfmt fixes for CI
1 parent b077bf3 commit 70a48be

7 files changed

Lines changed: 108 additions & 39 deletions

File tree

quickwit/quickwit-parquet-engine/src/sort_fields/column_type.rs

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,48 @@ pub struct ColumnDefaults {
125125
///
126126
/// Columns not in this table default to String, ascending.
127127
static WELL_KNOWN_COLUMNS: &[(&str, ColumnDefaults)] = &[
128-
(TIMESTAMP, ColumnDefaults { column_type: ColumnTypeId::Int64, descending: true }),
129-
("timestamp_secs", ColumnDefaults { column_type: ColumnTypeId::Int64, descending: true }),
130-
(TIEBREAKER, ColumnDefaults { column_type: ColumnTypeId::Int64, descending: false }),
131-
(TIMESERIES_ID, ColumnDefaults { column_type: ColumnTypeId::Int64, descending: false }),
132-
(METRIC_VALUE, ColumnDefaults { column_type: ColumnTypeId::Float64, descending: false }),
133-
("value", ColumnDefaults { column_type: ColumnTypeId::Float64, descending: false }),
128+
(
129+
TIMESTAMP,
130+
ColumnDefaults {
131+
column_type: ColumnTypeId::Int64,
132+
descending: true,
133+
},
134+
),
135+
(
136+
"timestamp_secs",
137+
ColumnDefaults {
138+
column_type: ColumnTypeId::Int64,
139+
descending: true,
140+
},
141+
),
142+
(
143+
TIEBREAKER,
144+
ColumnDefaults {
145+
column_type: ColumnTypeId::Int64,
146+
descending: false,
147+
},
148+
),
149+
(
150+
TIMESERIES_ID,
151+
ColumnDefaults {
152+
column_type: ColumnTypeId::Int64,
153+
descending: false,
154+
},
155+
),
156+
(
157+
METRIC_VALUE,
158+
ColumnDefaults {
159+
column_type: ColumnTypeId::Float64,
160+
descending: false,
161+
},
162+
),
163+
(
164+
"value",
165+
ColumnDefaults {
166+
column_type: ColumnTypeId::Float64,
167+
descending: false,
168+
},
169+
),
134170
];
135171

136172
const DEFAULT_COLUMN: ColumnDefaults = ColumnDefaults {

quickwit/quickwit-parquet-engine/src/sort_fields/parser.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
2121
use quickwit_proto::sortschema::{SortColumn, SortColumnDirection, SortSchema};
2222

23+
use super::SortFieldsError;
2324
use super::column_type::{ColumnTypeId, default_is_descending};
2425
use 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.
289293
fn 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) {
300310
fn 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)

quickwit/quickwit-parquet-engine/src/sort_fields/tests.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ fn test_schemas_to_string() {
907907
// key1 has type String == default, so no suffix. key2 has type Int64 != default, keeps __i.
908908
assert_eq!(
909909
actual,
910-
"test=key1:dense-string:+|timestamp:dense-int64:-/V2,\
911-
key2__i:dense-int64:+|timestamp:dense-int64:-/V2"
910+
"test=key1:dense-string:+|timestamp:dense-int64:-/V2,key2__i:dense-int64:+|\
911+
timestamp:dense-int64:-/V2"
912912
);
913913
}
914914

@@ -932,11 +932,26 @@ fn test_schemas_to_string_short() {
932932
#[test]
933933
fn test_column_type_try_from_u64_valid() {
934934
assert_eq!(ColumnTypeId::try_from(2u64).unwrap(), ColumnTypeId::Int64);
935-
assert_eq!(ColumnTypeId::try_from(10u64).unwrap(), ColumnTypeId::Float64);
936-
assert_eq!(ColumnTypeId::try_from(14u64).unwrap(), ColumnTypeId::String);
937-
assert_eq!(ColumnTypeId::try_from(17u64).unwrap(), ColumnTypeId::Sketch);
938-
assert_eq!(ColumnTypeId::try_from(20u64).unwrap(), ColumnTypeId::CpcSketch);
939-
assert_eq!(ColumnTypeId::try_from(22u64).unwrap(), ColumnTypeId::ItemSketch);
935+
assert_eq!(
936+
ColumnTypeId::try_from(10u64).unwrap(),
937+
ColumnTypeId::Float64
938+
);
939+
assert_eq!(
940+
ColumnTypeId::try_from(14u64).unwrap(),
941+
ColumnTypeId::String
942+
);
943+
assert_eq!(
944+
ColumnTypeId::try_from(17u64).unwrap(),
945+
ColumnTypeId::Sketch
946+
);
947+
assert_eq!(
948+
ColumnTypeId::try_from(20u64).unwrap(),
949+
ColumnTypeId::CpcSketch
950+
);
951+
assert_eq!(
952+
ColumnTypeId::try_from(22u64).unwrap(),
953+
ColumnTypeId::ItemSketch
954+
);
940955
}
941956

942957
#[test]

quickwit/quickwit-parquet-engine/src/sort_fields/validation.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::collections::HashSet;
1818

1919
use quickwit_proto::sortschema::{SortColumnDirection, SortSchema};
2020

21-
use super::column_type::{ColumnTypeId, TIEBREAKER, default_is_descending};
2221
use super::SortFieldsError;
22+
use super::column_type::{ColumnTypeId, TIEBREAKER, default_is_descending};
2323

2424
/// Name used for the special skip-builder schema that does not require timestamp.
2525
const DEFAULT_SKIP_BUILDER_SCHEMA_NAME: &str = "defaultSkipBuilderSchema";
@@ -41,9 +41,7 @@ fn is_timestamp_column(name: &str) -> bool {
4141
/// - No non-tiebreaker columns may appear after `timestamp`.
4242
pub fn validate_schema(schema: &SortSchema) -> Result<(), SortFieldsError> {
4343
if schema.column.is_empty() {
44-
return Err(SortFieldsError::ValidationError(
45-
"empty schema".to_string(),
46-
));
44+
return Err(SortFieldsError::ValidationError("empty schema".to_string()));
4745
}
4846

4947
let mut seen: HashSet<&str> = HashSet::new();

quickwit/quickwit-parquet-engine/src/sort_fields/window.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ pub fn window_start(
9090
timestamp_secs,
9191
duration_secs,
9292
);
93-
DateTime::from_timestamp(start_secs, 0).ok_or(SortFieldsError::WindowStartOutOfRange {
94-
timestamp_secs: start_secs,
95-
})
93+
DateTime::from_timestamp(start_secs, 0).ok_or(
94+
SortFieldsError::WindowStartOutOfRange {
95+
timestamp_secs: start_secs,
96+
},
97+
)
9698
}
9799

98100
#[cfg(test)]
@@ -215,7 +217,9 @@ mod tests {
215217
#[test]
216218
fn test_small_valid_divisors_also_accepted() {
217219
// The function accepts all positive divisors of 3600, not just >= 60.
218-
let small_valid = [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 30, 36, 40, 45, 48, 50];
220+
let small_valid = [
221+
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 30, 36, 40, 45, 48, 50,
222+
];
219223
for dur in small_valid {
220224
assert!(
221225
validate_window_duration(dur).is_ok(),
@@ -236,9 +240,6 @@ mod tests {
236240
fn test_non_divisor_error_message() {
237241
let err = validate_window_duration(7).unwrap_err();
238242
let msg = err.to_string();
239-
assert!(
240-
msg.contains("must evenly divide 3600"),
241-
"got: {msg}"
242-
);
243+
assert!(msg.contains("must evenly divide 3600"), "got: {msg}");
243244
}
244245
}

quickwit/quickwit-proto/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ pub mod indexing;
3737
pub mod ingest;
3838
pub mod metastore;
3939
pub mod search;
40-
pub mod types;
4140
pub mod sort_fields_error;
41+
pub mod types;
4242

4343
pub use error::{GrpcServiceError, ServiceError, ServiceErrorCode};
44-
pub use sort_fields_error::SortFieldsError;
4544
use search::ReportSplitsRequest;
45+
pub use sort_fields_error::SortFieldsError;
4646

4747
pub mod sortschema {
4848
include!("codegen/sortschema/sortschema.rs");

quickwit/quickwit-proto/src/sort_fields_error.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ pub enum SortFieldsError {
4949
UnknownColumnType(String),
5050

5151
/// Explicit column type does not match the type inferred from the suffix.
52-
#[error("column type doesn't match type deduced from suffix for {column}, deduced={from_suffix}, explicit={explicit}")]
52+
#[error(
53+
"column type doesn't match type deduced from suffix for {column}, deduced={from_suffix}, \
54+
explicit={explicit}"
55+
)]
5356
TypeMismatch {
5457
column: String,
5558
from_suffix: String,

0 commit comments

Comments
 (0)