Skip to content

Commit 1946a5a

Browse files
wjones127claude
andauthored
chore: upgrade Rust toolchain to 1.97.0 (#7712)
Bumps the pinned toolchain from 1.94.0 to 1.97.0 in `rust-toolchain.toml` (the `python/` and `java/lance-jni/` copies are symlinks to it) and fixes the clippy lints newly reported by 1.97 across the workspace. New lints fixed: - `manual_filter`, `manual_checked_ops`, `question_mark` - `useless_conversion`, `useless_borrows_in_formatting` - `collapsible_match`, `while_let_loop`, `explicit_counter_loop`, `unnecessary_sort_by` All fixes are behavior-preserving. `cargo clippy -- -D warnings` is clean across the main workspace (all features, all targets), `python/`, and `java/lance-jni/`; `cargo fmt --check` passes on all three. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of floating-point `NaN` values in range queries for more conservative, reliable results. * Prevented potential division-by-zero issues in decoding and statistics calculations. * Preserved correct behavior when processing all-null data and missing fields. * **Maintenance** * Updated the Rust toolchain used to build the project. * Simplified internal processing across indexing, scanning, encoding, storage, and query-planning components without changing expected behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5ba1e20 commit 1946a5a

36 files changed

Lines changed: 97 additions & 163 deletions

File tree

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# We keep this pinned to keep clippy and rustfmt in sync between local and CI.
22
# Feel free to upgrade to bring in new lints.
33
[toolchain]
4-
channel = "1.94.0"
4+
channel = "1.97.0"
55
components = ["rustfmt", "clippy", "rust-analyzer"]

rust/lance-arrow/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,13 +1022,7 @@ fn merge_list_struct(left: &dyn Array, right: &dyn Array) -> Arc<dyn Array> {
10221022
fn normalize_validity(
10231023
validity: Option<&arrow_buffer::NullBuffer>,
10241024
) -> Option<&arrow_buffer::NullBuffer> {
1025-
validity.and_then(|v| {
1026-
if v.null_count() == v.len() {
1027-
None
1028-
} else {
1029-
Some(v)
1030-
}
1031-
})
1025+
validity.filter(|v| v.null_count() != v.len())
10321026
}
10331027

10341028
/// Helper function to merge validity buffers from two struct arrays

rust/lance-datafusion/src/logical_expr.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,10 @@ pub fn resolve_column_type(expr: &Expr, schema: &Schema) -> Option<DataType> {
5151
field_path.push(c.name.as_str());
5252
break;
5353
}
54-
Expr::ScalarFunction(udf) => {
55-
if udf.name() == GetFieldFunc::default().name() {
56-
let name = get_as_string_scalar_opt(&udf.args[1])?;
57-
field_path.push(name);
58-
current_expr = &udf.args[0];
59-
} else {
60-
return None;
61-
}
54+
Expr::ScalarFunction(udf) if udf.name() == GetFieldFunc::default().name() => {
55+
let name = get_as_string_scalar_opt(&udf.args[1])?;
56+
field_path.push(name);
57+
current_expr = &udf.args[0];
6258
}
6359
_ => return None,
6460
}

rust/lance-datafusion/src/planner.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl Planner {
503503
}
504504
_ => Err(Error::invalid_input(format!(
505505
"Unsupported function args: {:?}",
506-
&func.args
506+
func.args
507507
))),
508508
}
509509
}
@@ -1062,13 +1062,9 @@ impl TreeNodeVisitor<'_> for ColumnCapturingVisitor {
10621062
self.columns.insert(path);
10631063
self.current_path.clear();
10641064
}
1065-
Expr::ScalarFunction(udf) => {
1066-
if udf.name() == GetFieldFunc::default().name() {
1067-
if let Some(name) = get_as_string_scalar_opt(&udf.args[1]) {
1068-
self.current_path.push_front(name.to_string())
1069-
} else {
1070-
self.current_path.clear();
1071-
}
1065+
Expr::ScalarFunction(udf) if udf.name() == GetFieldFunc::default().name() => {
1066+
if let Some(name) = get_as_string_scalar_opt(&udf.args[1]) {
1067+
self.current_path.push_front(name.to_string())
10721068
} else {
10731069
self.current_path.clear();
10741070
}

rust/lance-encoding/src/decoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,8 +1949,7 @@ impl StructuralBatchDecodeStream {
19491949
next_task.into_batch(emitted_batch_size_warning)?
19501950
};
19511951
let num_rows = batch.num_rows() as u64;
1952-
if num_rows > 0 {
1953-
let bpr = data_size / num_rows;
1952+
if let Some(bpr) = data_size.checked_div(num_rows) {
19541953
let prev = bytes_per_row_feedback.load(Ordering::Relaxed);
19551954
let next = if prev == 0 || bpr >= prev {
19561955
// First batch or actual size is larger than estimate:

rust/lance-encoding/src/encodings/physical/packed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl PerValueCompressor for PackedStructVariablePerValueEncoder {
323323
let mut field_data = Vec::with_capacity(self.fields.len());
324324
let mut field_metadata = Vec::with_capacity(self.fields.len());
325325

326-
for (field, child_block) in self.fields.iter().zip(struct_block.children.into_iter()) {
326+
for (field, child_block) in self.fields.iter().zip(struct_block.children) {
327327
let compressor = crate::compression::CompressionStrategy::create_per_value(
328328
&self.strategy,
329329
field,
@@ -688,7 +688,7 @@ impl VariablePerValueDecompressor for PackedStructVariablePerValueDecompressor {
688688
}
689689

690690
let mut children = Vec::with_capacity(self.fields.len());
691-
for (field, accumulator) in self.fields.iter().zip(accumulators.into_iter()) {
691+
for (field, accumulator) in self.fields.iter().zip(accumulators) {
692692
match (field, accumulator) {
693693
(
694694
VariablePackedStructFieldDecoder {

rust/lance-encoding/src/previous/encodings/logical/blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl BlobFieldEncoder {
318318
.nulls()
319319
.cloned()
320320
.unwrap_or(NullBuffer::new_valid(binarray.len()));
321-
for (w, is_valid) in binarray.value_offsets().windows(2).zip(nulls.into_iter()) {
321+
for (w, is_valid) in binarray.value_offsets().windows(2).zip(&nulls) {
322322
if is_valid {
323323
let start = w[0] as u64;
324324
let end = w[1] as u64;

rust/lance-file/src/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ impl FileMetadataProvider {
19391939
.collect::<Vec<_>>();
19401940
let metadata_bytes = io.submit_request(ranges, 0).await?;
19411941
for ((result_index, column_index, _), bytes) in
1942-
missing_columns.into_iter().zip(metadata_bytes.into_iter())
1942+
missing_columns.into_iter().zip(metadata_bytes)
19431943
{
19441944
let column_metadata = pbfile::ColumnMetadata::decode(bytes)?;
19451945
let column_info = FileReader::meta_to_col_info(

rust/lance-index/src/scalar/bitmap.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,7 @@ impl BitmapBatchWriter {
891891
return Ok(());
892892
}
893893
let keys_array =
894-
ScalarValue::iter_to_array(self.keys.drain(..).collect::<Vec<_>>().into_iter())
895-
.unwrap();
894+
ScalarValue::iter_to_array(self.keys.drain(..).collect::<Vec<_>>()).unwrap();
896895
let total_size: usize = self.serialized.iter().map(|b| b.len()).sum();
897896
let mut binary_builder = BinaryBuilder::with_capacity(self.serialized.len(), total_size);
898897
for b in self.serialized.drain(..) {
@@ -1123,10 +1122,7 @@ async fn drain_same_key_bitmaps(
11231122
let merged_key = OrderableScalarValue(key);
11241123
advance_cursor_and_push(cursors, heap, item.shard_idx).await?;
11251124

1126-
loop {
1127-
let Some(Reverse(next_item)) = heap.peek() else {
1128-
break;
1129-
};
1125+
while let Some(Reverse(next_item)) = heap.peek() {
11301126
if next_item.key != merged_key {
11311127
break;
11321128
}
@@ -1280,7 +1276,7 @@ impl BitmapIndexPlugin {
12801276
let bitmap_size = bytes.len();
12811277

12821278
if cur_bytes + bitmap_size > MAX_BITMAP_ARRAY_LENGTH {
1283-
let keys_array = ScalarValue::iter_to_array(cur_keys.clone().into_iter()).unwrap();
1279+
let keys_array = ScalarValue::iter_to_array(cur_keys.clone()).unwrap();
12841280
let mut binary_builder = BinaryBuilder::new();
12851281
for b in &cur_bitmaps {
12861282
binary_builder.append_value(b);

rust/lance-index/src/scalar/btree.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,12 +5327,8 @@ mod tests {
53275327
mapping.insert(old_id, None);
53285328
}
53295329

5330-
let mut new_id_counter = 100_000;
5331-
53325330
// Remap all other rows
5333-
for old_id in (0..1000).chain(10000..15000) {
5334-
let new_id = new_id_counter;
5335-
new_id_counter += 1;
5331+
for (new_id, old_id) in (100_000..).zip((0..1000).chain(10000..15000)) {
53365332
mapping.insert(old_id, Some(new_id));
53375333
}
53385334

0 commit comments

Comments
 (0)