Skip to content

Commit 67fdd9b

Browse files
committed
Bump MSRV to 1.88, fix warnings and clippy errors.
1 parent 9fa3776 commit 67fdd9b

34 files changed

+316
-324
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ version = "0.7.0"
3636
license = "Apache-2.0"
3737
repository = "https://github.com/apache/iceberg-rust"
3838
# Check the MSRV policy in README.md before changing this
39-
rust-version = "1.87"
39+
rust-version = "1.88"
40+
41+
[workspace.lints.rust]
42+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(FALSE)'] }
4043

4144
[workspace.dependencies]
4245
anyhow = "1.0.72"

crates/catalog/glue/src/catalog.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,33 +151,33 @@ impl GlueCatalog {
151151
async fn new(config: GlueCatalogConfig) -> Result<Self> {
152152
let sdk_config = create_sdk_config(&config.props, config.uri.as_ref()).await;
153153
let mut file_io_props = config.props.clone();
154-
if !file_io_props.contains_key(S3_ACCESS_KEY_ID) {
155-
if let Some(access_key_id) = file_io_props.get(AWS_ACCESS_KEY_ID) {
156-
file_io_props.insert(S3_ACCESS_KEY_ID.to_string(), access_key_id.to_string());
157-
}
154+
if !file_io_props.contains_key(S3_ACCESS_KEY_ID)
155+
&& let Some(access_key_id) = file_io_props.get(AWS_ACCESS_KEY_ID)
156+
{
157+
file_io_props.insert(S3_ACCESS_KEY_ID.to_string(), access_key_id.to_string());
158158
}
159-
if !file_io_props.contains_key(S3_SECRET_ACCESS_KEY) {
160-
if let Some(secret_access_key) = file_io_props.get(AWS_SECRET_ACCESS_KEY) {
161-
file_io_props.insert(
162-
S3_SECRET_ACCESS_KEY.to_string(),
163-
secret_access_key.to_string(),
164-
);
165-
}
159+
if !file_io_props.contains_key(S3_SECRET_ACCESS_KEY)
160+
&& let Some(secret_access_key) = file_io_props.get(AWS_SECRET_ACCESS_KEY)
161+
{
162+
file_io_props.insert(
163+
S3_SECRET_ACCESS_KEY.to_string(),
164+
secret_access_key.to_string(),
165+
);
166166
}
167-
if !file_io_props.contains_key(S3_REGION) {
168-
if let Some(region) = file_io_props.get(AWS_REGION_NAME) {
169-
file_io_props.insert(S3_REGION.to_string(), region.to_string());
170-
}
167+
if !file_io_props.contains_key(S3_REGION)
168+
&& let Some(region) = file_io_props.get(AWS_REGION_NAME)
169+
{
170+
file_io_props.insert(S3_REGION.to_string(), region.to_string());
171171
}
172-
if !file_io_props.contains_key(S3_SESSION_TOKEN) {
173-
if let Some(session_token) = file_io_props.get(AWS_SESSION_TOKEN) {
174-
file_io_props.insert(S3_SESSION_TOKEN.to_string(), session_token.to_string());
175-
}
172+
if !file_io_props.contains_key(S3_SESSION_TOKEN)
173+
&& let Some(session_token) = file_io_props.get(AWS_SESSION_TOKEN)
174+
{
175+
file_io_props.insert(S3_SESSION_TOKEN.to_string(), session_token.to_string());
176176
}
177-
if !file_io_props.contains_key(S3_ENDPOINT) {
178-
if let Some(aws_endpoint) = config.uri.as_ref() {
179-
file_io_props.insert(S3_ENDPOINT.to_string(), aws_endpoint.to_string());
180-
}
177+
if !file_io_props.contains_key(S3_ENDPOINT)
178+
&& let Some(aws_endpoint) = config.uri.as_ref()
179+
{
180+
file_io_props.insert(S3_ENDPOINT.to_string(), aws_endpoint.to_string());
181181
}
182182

183183
let client = aws_sdk_glue::Client::new(&sdk_config);

crates/iceberg/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ keywords = ["iceberg"]
2828
license = { workspace = true }
2929
repository = { workspace = true }
3030

31+
[lints]
32+
workspace = true
33+
3134
[features]
3235
default = ["storage-memory", "storage-fs", "storage-s3", "tokio"]
3336
storage-all = ["storage-memory", "storage-fs", "storage-s3", "storage-gcs"]

crates/iceberg/src/arrow/reader.rs

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,10 @@ impl ArrowReader {
485485
// we need to call next() to update the cache with the newly positioned value.
486486
delete_vector_iter.advance_to(next_row_group_base_idx);
487487
// Only update the cache if the cached value is stale (in the skipped range)
488-
if let Some(cached_idx) = next_deleted_row_idx_opt {
489-
if cached_idx < next_row_group_base_idx {
490-
next_deleted_row_idx_opt = delete_vector_iter.next();
491-
}
488+
if let Some(cached_idx) = next_deleted_row_idx_opt
489+
&& cached_idx < next_row_group_base_idx
490+
{
491+
next_deleted_row_idx_opt = delete_vector_iter.next();
492492
}
493493

494494
// still increment the current page base index but then skip to the next row group
@@ -842,10 +842,10 @@ impl ArrowReader {
842842
};
843843

844844
// If all row groups were filtered out, return an empty RowSelection (select no rows)
845-
if let Some(selected_row_groups) = selected_row_groups {
846-
if selected_row_groups.is_empty() {
847-
return Ok(RowSelection::from(Vec::new()));
848-
}
845+
if let Some(selected_row_groups) = selected_row_groups
846+
&& selected_row_groups.is_empty()
847+
{
848+
return Ok(RowSelection::from(Vec::new()));
849849
}
850850

851851
let mut selected_row_groups_idx = 0;
@@ -878,10 +878,10 @@ impl ArrowReader {
878878

879879
results.push(selections_for_page);
880880

881-
if let Some(selected_row_groups) = selected_row_groups {
882-
if selected_row_groups_idx == selected_row_groups.len() {
883-
break;
884-
}
881+
if let Some(selected_row_groups) = selected_row_groups
882+
&& selected_row_groups_idx == selected_row_groups.len()
883+
{
884+
break;
885885
}
886886
}
887887

@@ -1012,13 +1012,13 @@ fn apply_name_mapping_to_arrow_schema(
10121012

10131013
let mut metadata = field.metadata().clone();
10141014

1015-
if let Some(mapped_field) = mapped_field_opt {
1016-
if let Some(field_id) = mapped_field.field_id() {
1017-
// Field found in mapping with a field_id → assign it
1018-
metadata.insert(PARQUET_FIELD_ID_META_KEY.to_string(), field_id.to_string());
1019-
}
1020-
// If field_id is None, leave the field without an ID (will be filtered by projection)
1015+
if let Some(mapped_field) = mapped_field_opt
1016+
&& let Some(field_id) = mapped_field.field_id()
1017+
{
1018+
// Field found in mapping with a field_id → assign it
1019+
metadata.insert(PARQUET_FIELD_ID_META_KEY.to_string(), field_id.to_string());
10211020
}
1021+
// If field_id is None, leave the field without an ID (will be filtered by projection)
10221022
// If field not found in mapping, leave it without an ID (will be filtered by projection)
10231023

10241024
Field::new(field.name(), field.data_type().clone(), field.is_nullable())
@@ -2712,15 +2712,14 @@ message schema {
27122712
// Step 4: Verify we got 199 rows (not 200)
27132713
let total_rows: usize = result.iter().map(|b| b.num_rows()).sum();
27142714

2715-
println!("Total rows read: {}", total_rows);
2715+
println!("Total rows read: {total_rows}");
27162716
println!("Expected: 199 rows (deleted row 199 which had id=200)");
27172717

27182718
// This assertion will FAIL before the fix and PASS after the fix
27192719
assert_eq!(
27202720
total_rows, 199,
2721-
"Expected 199 rows after deleting row 199, but got {} rows. \
2722-
The bug causes position deletes in later row groups to be ignored.",
2723-
total_rows
2721+
"Expected 199 rows after deleting row 199, but got {total_rows} rows. \
2722+
The bug causes position deletes in later row groups to be ignored."
27242723
);
27252724

27262725
// Verify the deleted row (id=200) is not present
@@ -2931,16 +2930,15 @@ message schema {
29312930
// Row group 1 has 100 rows (ids 101-200), minus 1 delete (id=200) = 99 rows
29322931
let total_rows: usize = result.iter().map(|b| b.num_rows()).sum();
29332932

2934-
println!("Total rows read from row group 1: {}", total_rows);
2933+
println!("Total rows read from row group 1: {total_rows}");
29352934
println!("Expected: 99 rows (row group 1 has 100 rows, 1 delete at position 199)");
29362935

29372936
// This assertion will FAIL before the fix and PASS after the fix
29382937
assert_eq!(
29392938
total_rows, 99,
2940-
"Expected 99 rows from row group 1 after deleting position 199, but got {} rows. \
2939+
"Expected 99 rows from row group 1 after deleting position 199, but got {total_rows} rows. \
29412940
The bug causes position deletes to be lost when advance_to() is followed by next() \
2942-
when skipping unselected row groups.",
2943-
total_rows
2941+
when skipping unselected row groups."
29442942
);
29452943

29462944
// Verify the deleted row (id=200) is not present
@@ -3222,7 +3220,7 @@ message schema {
32223220
start: 0,
32233221
length: 0,
32243222
record_count: None,
3225-
data_file_path: format!("{}/1.parquet", table_location),
3223+
data_file_path: format!("{table_location}/1.parquet"),
32263224
data_file_format: DataFileFormat::Parquet,
32273225
schema: schema.clone(),
32283226
project_field_ids: vec![1, 2],
@@ -3319,7 +3317,7 @@ message schema {
33193317
start: 0,
33203318
length: 0,
33213319
record_count: None,
3322-
data_file_path: format!("{}/1.parquet", table_location),
3320+
data_file_path: format!("{table_location}/1.parquet"),
33233321
data_file_format: DataFileFormat::Parquet,
33243322
schema: schema.clone(),
33253323
project_field_ids: vec![1, 3],
@@ -3405,7 +3403,7 @@ message schema {
34053403
start: 0,
34063404
length: 0,
34073405
record_count: None,
3408-
data_file_path: format!("{}/1.parquet", table_location),
3406+
data_file_path: format!("{table_location}/1.parquet"),
34093407
data_file_format: DataFileFormat::Parquet,
34103408
schema: schema.clone(),
34113409
project_field_ids: vec![1, 2, 3],
@@ -3505,7 +3503,7 @@ message schema {
35053503
start: 0,
35063504
length: 0,
35073505
record_count: None,
3508-
data_file_path: format!("{}/1.parquet", table_location),
3506+
data_file_path: format!("{table_location}/1.parquet"),
35093507
data_file_format: DataFileFormat::Parquet,
35103508
schema: schema.clone(),
35113509
project_field_ids: vec![1, 2],
@@ -3546,7 +3544,7 @@ message schema {
35463544
assert_eq!(all_values.len(), 6);
35473545

35483546
for i in 0..6 {
3549-
assert_eq!(all_names[i], format!("name_{}", i));
3547+
assert_eq!(all_names[i], format!("name_{i}"));
35503548
assert_eq!(all_values[i], i as i32);
35513549
}
35523550
}
@@ -3634,7 +3632,7 @@ message schema {
36343632
start: 0,
36353633
length: 0,
36363634
record_count: None,
3637-
data_file_path: format!("{}/1.parquet", table_location),
3635+
data_file_path: format!("{table_location}/1.parquet"),
36383636
data_file_format: DataFileFormat::Parquet,
36393637
schema: schema.clone(),
36403638
project_field_ids: vec![1, 2],
@@ -3730,7 +3728,7 @@ message schema {
37303728
start: 0,
37313729
length: 0,
37323730
record_count: None,
3733-
data_file_path: format!("{}/1.parquet", table_location),
3731+
data_file_path: format!("{table_location}/1.parquet"),
37343732
data_file_format: DataFileFormat::Parquet,
37353733
schema: schema.clone(),
37363734
project_field_ids: vec![1, 5, 2],
@@ -3839,7 +3837,7 @@ message schema {
38393837
start: 0,
38403838
length: 0,
38413839
record_count: None,
3842-
data_file_path: format!("{}/1.parquet", table_location),
3840+
data_file_path: format!("{table_location}/1.parquet"),
38433841
data_file_format: DataFileFormat::Parquet,
38443842
schema: schema.clone(),
38453843
project_field_ids: vec![1, 2, 3],
@@ -3978,7 +3976,7 @@ message schema {
39783976
start: 0,
39793977
length: 0,
39803978
record_count: None,
3981-
data_file_path: format!("{}/data.parquet", table_location),
3979+
data_file_path: format!("{table_location}/data.parquet"),
39823980
data_file_format: DataFileFormat::Parquet,
39833981
schema: schema.clone(),
39843982
project_field_ids: vec![1, 2],

crates/iceberg/src/arrow/record_batch_projector.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,24 @@ impl RecordBatchProjector {
133133
{
134134
for (pos, field) in fields.iter().enumerate() {
135135
let id = field_id_fetch_func(field)?;
136-
if let Some(id) = id {
137-
if target_field_id == id {
138-
index_vec.push(pos);
139-
return Ok(Some(field.clone()));
140-
}
136+
if let Some(id) = id
137+
&& target_field_id == id
138+
{
139+
index_vec.push(pos);
140+
return Ok(Some(field.clone()));
141141
}
142-
if let DataType::Struct(inner) = field.data_type() {
143-
if searchable_field_func(field) {
144-
if let Some(res) = Self::fetch_field_index(
145-
inner,
146-
index_vec,
147-
target_field_id,
148-
field_id_fetch_func,
149-
searchable_field_func,
150-
)? {
151-
index_vec.push(pos);
152-
return Ok(Some(res));
153-
}
154-
}
142+
if let DataType::Struct(inner) = field.data_type()
143+
&& searchable_field_func(field)
144+
&& let Some(res) = Self::fetch_field_index(
145+
inner,
146+
index_vec,
147+
target_field_id,
148+
field_id_fetch_func,
149+
searchable_field_func,
150+
)?
151+
{
152+
index_vec.push(pos);
153+
return Ok(Some(res));
155154
}
156155
}
157156
Ok(None)

crates/iceberg/src/arrow/record_batch_transformer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl RecordBatchTransformer {
492492
let this_field_id = field_id_str.parse().map_err(|e| {
493493
Error::new(
494494
ErrorKind::DataInvalid,
495-
format!("field id not parseable as an i32: {}", e),
495+
format!("field id not parseable as an i32: {e}"),
496496
)
497497
})?;
498498

@@ -615,7 +615,7 @@ impl RecordBatchTransformer {
615615
(dt, _) => {
616616
return Err(Error::new(
617617
ErrorKind::Unexpected,
618-
format!("unexpected target column type {}", dt),
618+
format!("unexpected target column type {dt}"),
619619
));
620620
}
621621
})

crates/iceberg/src/arrow/value.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,15 @@ impl SchemaWithPartnerVisitor<ArrayRef> for ArrowArrayToIcebergStructConverter {
258258
"The partner is not a decimal128 array",
259259
)
260260
})?;
261-
if let DataType::Decimal128(arrow_precision, arrow_scale) = array.data_type() {
262-
if *arrow_precision as u32 != *precision || *arrow_scale as u32 != *scale {
263-
return Err(Error::new(
264-
ErrorKind::DataInvalid,
265-
format!(
266-
"The precision or scale ({arrow_precision},{arrow_scale}) of arrow decimal128 array is not compatible with iceberg decimal type ({precision},{scale})"
267-
),
268-
));
269-
}
261+
if let DataType::Decimal128(arrow_precision, arrow_scale) = array.data_type()
262+
&& (*arrow_precision as u32 != *precision || *arrow_scale as u32 != *scale)
263+
{
264+
return Err(Error::new(
265+
ErrorKind::DataInvalid,
266+
format!(
267+
"The precision or scale ({arrow_precision},{arrow_scale}) of arrow decimal128 array is not compatible with iceberg decimal type ({precision},{scale})"
268+
),
269+
));
270270
}
271271
Ok(array.iter().map(|v| v.map(Literal::decimal)).collect())
272272
}
@@ -348,10 +348,10 @@ impl SchemaWithPartnerVisitor<ArrayRef> for ArrowArrayToIcebergStructConverter {
348348
} else if let Some(array) = partner.as_any().downcast_ref::<StringArray>() {
349349
Ok(array.iter().map(|v| v.map(Literal::string)).collect())
350350
} else {
351-
return Err(Error::new(
351+
Err(Error::new(
352352
ErrorKind::DataInvalid,
353353
"The partner is not a string array",
354-
));
354+
))
355355
}
356356
}
357357
PrimitiveType::Uuid => {
@@ -415,10 +415,10 @@ impl SchemaWithPartnerVisitor<ArrayRef> for ArrowArrayToIcebergStructConverter {
415415
.map(|v| v.map(|v| Literal::binary(v.to_vec())))
416416
.collect())
417417
} else {
418-
return Err(Error::new(
418+
Err(Error::new(
419419
ErrorKind::DataInvalid,
420420
"The partner is not a binary array",
421-
));
421+
))
422422
}
423423
}
424424
}

crates/iceberg/src/catalog/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,13 +1000,13 @@ mod _serde_set_statistics {
10001000
snapshot_id,
10011001
statistics,
10021002
} = SetStatistics::deserialize(deserializer)?;
1003-
if let Some(snapshot_id) = snapshot_id {
1004-
if snapshot_id != statistics.snapshot_id {
1005-
return Err(serde::de::Error::custom(format!(
1006-
"Snapshot id to set {snapshot_id} does not match the statistics file snapshot id {}",
1007-
statistics.snapshot_id
1008-
)));
1009-
}
1003+
if let Some(snapshot_id) = snapshot_id
1004+
&& snapshot_id != statistics.snapshot_id
1005+
{
1006+
return Err(serde::de::Error::custom(format!(
1007+
"Snapshot id to set {snapshot_id} does not match the statistics file snapshot id {}",
1008+
statistics.snapshot_id
1009+
)));
10101010
}
10111011

10121012
Ok(statistics)

0 commit comments

Comments
 (0)