Skip to content

Commit d8f75fc

Browse files
committed
clippy fixes
1 parent 9e370ec commit d8f75fc

File tree

20 files changed

+246
-251
lines changed

20 files changed

+246
-251
lines changed

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/src/arrow/reader.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ impl ArrowReader {
443443
// we need to call next() to update the cache with the newly positioned value.
444444
delete_vector_iter.advance_to(next_row_group_base_idx);
445445
// Only update the cache if the cached value is stale (in the skipped range)
446-
if let Some(cached_idx) = next_deleted_row_idx_opt {
447-
if cached_idx < next_row_group_base_idx {
448-
next_deleted_row_idx_opt = delete_vector_iter.next();
449-
}
446+
if let Some(cached_idx) = next_deleted_row_idx_opt
447+
&& cached_idx < next_row_group_base_idx
448+
{
449+
next_deleted_row_idx_opt = delete_vector_iter.next();
450450
}
451451

452452
// still increment the current page base index but then skip to the next row group
@@ -800,10 +800,10 @@ impl ArrowReader {
800800
};
801801

802802
// If all row groups were filtered out, return an empty RowSelection (select no rows)
803-
if let Some(selected_row_groups) = selected_row_groups {
804-
if selected_row_groups.is_empty() {
805-
return Ok(RowSelection::from(Vec::new()));
806-
}
803+
if let Some(selected_row_groups) = selected_row_groups
804+
&& selected_row_groups.is_empty()
805+
{
806+
return Ok(RowSelection::from(Vec::new()));
807807
}
808808

809809
let mut selected_row_groups_idx = 0;
@@ -836,10 +836,10 @@ impl ArrowReader {
836836

837837
results.push(selections_for_page);
838838

839-
if let Some(selected_row_groups) = selected_row_groups {
840-
if selected_row_groups_idx == selected_row_groups.len() {
841-
break;
842-
}
839+
if let Some(selected_row_groups) = selected_row_groups
840+
&& selected_row_groups_idx == selected_row_groups.len()
841+
{
842+
break;
843843
}
844844
}
845845

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/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)

crates/iceberg/src/delete_vector.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl DeleteVector {
3636
}
3737
}
3838

39-
pub fn iter(&self) -> DeleteVectorIterator {
39+
pub fn iter(&self) -> DeleteVectorIterator<'_> {
4040
let outer = self.inner.bitmaps();
4141
DeleteVectorIterator { outer, inner: None }
4242
}
@@ -93,10 +93,10 @@ impl Iterator for DeleteVectorIterator<'_> {
9393
type Item = u64;
9494

9595
fn next(&mut self) -> Option<Self::Item> {
96-
if let Some(inner) = &mut self.inner {
97-
if let Some(inner_next) = inner.bitmap_iter.next() {
98-
return Some(u64::from(inner.high_bits) << 32 | u64::from(inner_next));
99-
}
96+
if let Some(inner) = &mut self.inner
97+
&& let Some(inner_next) = inner.bitmap_iter.next()
98+
{
99+
return Some(u64::from(inner.high_bits) << 32 | u64::from(inner_next));
100100
}
101101

102102
if let Some((high_bits, next_bitmap)) = self.outer.next() {

crates/iceberg/src/expr/visitors/manifest_evaluator.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ impl BoundPredicateVisitor for ManifestFilterVisitor<'_> {
161161
_predicate: &BoundPredicate,
162162
) -> crate::Result<bool> {
163163
let field = self.field_summary_for_reference(reference);
164-
if let Some(contains_nan) = field.contains_nan {
165-
if !contains_nan {
166-
return ROWS_CANNOT_MATCH;
167-
}
164+
if let Some(contains_nan) = field.contains_nan
165+
&& !contains_nan
166+
{
167+
return ROWS_CANNOT_MATCH;
168168
}
169169

170170
if ManifestFilterVisitor::are_all_null(field, &reference.field().field_type) {
@@ -389,16 +389,16 @@ impl BoundPredicateVisitor for ManifestFilterVisitor<'_> {
389389
return ROWS_MIGHT_MATCH;
390390
}
391391

392-
if prefix.as_bytes().eq(&lower_bound[..prefix_len]) {
393-
if let Some(upper_bound) = &field.upper_bound {
394-
// if upper is shorter than the prefix then upper can't start with the prefix
395-
if prefix_len > upper_bound.len() {
396-
return ROWS_MIGHT_MATCH;
397-
}
392+
if prefix.as_bytes().eq(&lower_bound[..prefix_len])
393+
&& let Some(upper_bound) = &field.upper_bound
394+
{
395+
// if upper is shorter than the prefix then upper can't start with the prefix
396+
if prefix_len > upper_bound.len() {
397+
return ROWS_MIGHT_MATCH;
398+
}
398399

399-
if prefix.as_bytes().eq(&upper_bound[..prefix_len]) {
400-
return ROWS_CANNOT_MATCH;
401-
}
400+
if prefix.as_bytes().eq(&upper_bound[..prefix_len]) {
401+
return ROWS_CANNOT_MATCH;
402402
}
403403
}
404404
}

crates/iceberg/src/expr/visitors/page_index_evaluator.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -545,16 +545,16 @@ impl BoundPredicateVisitor for PageIndexEvaluator<'_> {
545545
return Ok(false);
546546
}
547547

548-
if let Some(min) = min {
549-
if min.gt(datum) {
550-
return Ok(false);
551-
}
548+
if let Some(min) = min
549+
&& min.gt(datum)
550+
{
551+
return Ok(false);
552552
}
553553

554-
if let Some(max) = max {
555-
if max.lt(datum) {
556-
return Ok(false);
557-
}
554+
if let Some(max) = max
555+
&& max.lt(datum)
556+
{
557+
return Ok(false);
558558
}
559559

560560
Ok(true)
@@ -793,6 +793,7 @@ impl BoundPredicateVisitor for PageIndexEvaluator<'_> {
793793
// 3. Use parquet's internal test module approach (requires being in same crate)
794794

795795
#[cfg(all(test, feature = "page_index_tests_disabled"))]
796+
#[allow(unexpected_cfgs)]
796797
mod tests {
797798
use std::collections::HashMap;
798799
use std::sync::Arc;

crates/iceberg/src/expr/visitors/strict_metrics_evaluator.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ impl<'a> StrictMetricsEvaluator<'a> {
129129
self.upper_bound(field_id)
130130
};
131131

132-
if let Some(bound) = bound {
133-
if cmp_fn(bound, datum) {
134-
return ROWS_MUST_MATCH;
135-
}
132+
if let Some(bound) = bound
133+
&& cmp_fn(bound, datum)
134+
{
135+
return ROWS_MUST_MATCH;
136136
}
137137

138138
ROWS_MIGHT_NOT_MATCH
@@ -219,10 +219,10 @@ impl BoundPredicateVisitor for StrictMetricsEvaluator<'_> {
219219
) -> crate::Result<bool> {
220220
let field_id = reference.field().id;
221221

222-
if let Some(&nan_count) = self.nan_count(field_id) {
223-
if nan_count == 0 {
224-
return ROWS_MUST_MATCH;
225-
}
222+
if let Some(&nan_count) = self.nan_count(field_id)
223+
&& nan_count == 0
224+
{
225+
return ROWS_MUST_MATCH;
226226
}
227227

228228
if self.contains_nulls_only(field_id) {
@@ -258,10 +258,10 @@ impl BoundPredicateVisitor for StrictMetricsEvaluator<'_> {
258258
) -> crate::Result<bool> {
259259
let field_id = reference.field().id;
260260

261-
if let Some(lower) = self.lower_bound(field_id) {
262-
if lower.is_nan() {
263-
return ROWS_MIGHT_NOT_MATCH;
264-
}
261+
if let Some(lower) = self.lower_bound(field_id)
262+
&& lower.is_nan()
263+
{
264+
return ROWS_MIGHT_NOT_MATCH;
265265
}
266266

267267
self.visit_inequality(reference, datum, PartialOrd::gt, true)

crates/iceberg/src/inspect/metadata_table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ impl<'a> MetadataTable<'a> {
7171
}
7272

7373
/// Get the snapshots table.
74-
pub fn snapshots(&self) -> SnapshotsTable {
74+
pub fn snapshots(&self) -> SnapshotsTable<'_> {
7575
SnapshotsTable::new(self.0)
7676
}
7777

7878
/// Get the manifests table.
79-
pub fn manifests(&self) -> ManifestsTable {
79+
pub fn manifests(&self) -> ManifestsTable<'_> {
8080
ManifestsTable::new(self.0)
8181
}
8282
}

0 commit comments

Comments
 (0)