Skip to content

Commit 5fcb4ef

Browse files
sionsmithclaude
andcommitted
fix: resolve all clippy warnings for CI compliance
- Fix useless_conversion warnings (DateTime::from()) - Fix len_zero warnings (use !is_empty()) - Fix if_same_then_else in hive.rs and glue.rs - Fix unnecessary_to_owned warnings - Fix unnecessary_cast warnings - Fix match_result_ok warnings - Fix useless_vec warnings (use array literals) - Fix map_identity warnings - Add #[allow(dead_code)] to intentionally unused fields - Remove unused imports - Add missing imports (NessieCatalogConfig, AtomicU32, SnapshotCommitResult) - Fix test code with proper type annotations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d4ee61b commit 5fcb4ef

18 files changed

Lines changed: 65 additions & 85 deletions

crates/k2i-core/src/buffer/hot_buffer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ struct ColumnBuilders {
132132
memory_bytes: usize,
133133
}
134134

135+
#[allow(dead_code)]
135136
struct BufferStats {
136137
total_records: AtomicU64,
137138
total_bytes: AtomicUsize,

crates/k2i-core/src/config.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl Default for RestCatalogConfig {
333333
}
334334

335335
/// AWS Glue catalog advanced configuration.
336-
#[derive(Debug, Clone, Deserialize, Serialize)]
336+
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
337337
pub struct GlueCatalogConfig {
338338
/// IAM role ARN to assume
339339
#[serde(default)]
@@ -348,16 +348,6 @@ pub struct GlueCatalogConfig {
348348
pub catalog_id: Option<String>,
349349
}
350350

351-
impl Default for GlueCatalogConfig {
352-
fn default() -> Self {
353-
Self {
354-
role_arn: None,
355-
external_id: None,
356-
catalog_id: None,
357-
}
358-
}
359-
}
360-
361351
/// Nessie catalog advanced configuration.
362352
///
363353
/// Nessie provides Git-like versioned data lake management.

crates/k2i-core/src/health.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub enum HealthStatus {
3131
/// Health check manager for tracking component health.
3232
pub struct HealthCheck {
3333
components: RwLock<HashMap<String, ComponentStatus>>,
34+
#[allow(dead_code)]
3435
started_at: Option<Instant>,
3536
job_running: RwLock<bool>,
3637
}

crates/k2i-core/src/iceberg/factory.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ impl CatalogFactory for RestCatalogFactory {
276276

277277
/// REST catalog client configuration.
278278
#[derive(Debug, Clone)]
279+
#[allow(dead_code)]
279280
pub struct RestClientConfig {
280281
/// REST API base URI
281282
pub base_uri: String,
@@ -325,11 +326,11 @@ struct CachedToken {
325326
impl RestCatalogClient {
326327
/// Create a new REST catalog client.
327328
pub async fn new(config: &IcebergConfig, rest_uri: String) -> Result<Self> {
328-
let timeout = Duration::from_secs(config.rest.request_timeout_seconds.unwrap_or(30) as u64);
329+
let timeout = Duration::from_secs(config.rest.request_timeout_seconds.unwrap_or(30));
329330

330331
let http_client = Client::builder()
331332
.timeout(timeout)
332-
.pool_max_idle_per_host(config.catalog_manager.connection_pool_size as usize)
333+
.pool_max_idle_per_host(config.catalog_manager.connection_pool_size)
333334
.build()
334335
.map_err(|e| Error::Config(format!("Failed to create HTTP client: {}", e)))?;
335336

@@ -412,7 +413,7 @@ impl RestCatalogClient {
412413
.as_ref()
413414
.ok_or_else(|| Error::Config("OAuth2 requires client_secret".into()))?;
414415

415-
let request = rest_api::OAuthTokenRequest {
416+
let _request = rest_api::OAuthTokenRequest {
416417
grant_type: "client_credentials".to_string(),
417418
client_id: Some(client_id.clone()),
418419
client_secret: Some(client_secret.clone()),

crates/k2i-core/src/iceberg/glue.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use crate::circuit_breaker::{CircuitBreaker, CircuitBreakerConfig};
1515
use crate::config::{CatalogType, IcebergConfig};
1616
use crate::iceberg::factory::{
17-
CatalogFactory, CatalogHealth, CatalogOperations, DataFileInfo, SchemaFieldInfo,
18-
SnapshotCommit, SnapshotCommitResult, TableInfo, TableSchema,
17+
CatalogFactory, CatalogHealth, CatalogOperations, SchemaFieldInfo, SnapshotCommit,
18+
SnapshotCommitResult, TableInfo, TableSchema,
1919
};
2020
use crate::{Error, IcebergError, Result};
2121
use async_trait::async_trait;
@@ -201,8 +201,7 @@ impl GlueCatalogClient {
201201
.and_then(|s| s.parse::<i64>().ok());
202202

203203
// Extract table properties
204-
let properties: HashMap<String, String> =
205-
table.parameters().map(|p| p.clone()).unwrap_or_default();
204+
let properties: HashMap<String, String> = table.parameters().cloned().unwrap_or_default();
206205

207206
Ok(TableInfo {
208207
namespace: namespace.to_string(),
@@ -261,9 +260,7 @@ impl GlueCatalogClient {
261260
// Handle complex types or unknown types
262261
if glue_type.starts_with("array<") {
263262
format!("list<{}>", &glue_type[6..glue_type.len() - 1])
264-
} else if glue_type.starts_with("map<") {
265-
glue_type.to_string()
266-
} else if glue_type.starts_with("struct<") {
263+
} else if glue_type.starts_with("map<") || glue_type.starts_with("struct<") {
267264
glue_type.to_string()
268265
} else {
269266
"string".to_string() // Default fallback
@@ -445,7 +442,7 @@ impl CatalogOperations for GlueCatalogClient {
445442

446443
let database_input = aws_sdk_glue::types::DatabaseInput::builder()
447444
.name(namespace)
448-
.description(format!("Iceberg database created by k2i"))
445+
.description("Iceberg database created by k2i".to_string())
449446
.location_uri(format!("{}/{}", self.config.warehouse_path, namespace))
450447
.build()
451448
.map_err(|e| Error::Config(format!("Failed to build database input: {}", e)))?;

crates/k2i-core/src/iceberg/hive.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,10 @@ impl HiveCatalogClient {
299299
if hive_type.starts_with("array<") {
300300
let inner = &hive_type[6..hive_type.len() - 1];
301301
format!("list<{}>", self.hive_type_to_iceberg_type(inner))
302-
} else if hive_type.starts_with("map<") {
303-
hive_type.to_string()
304-
} else if hive_type.starts_with("struct<") {
305-
hive_type.to_string()
306-
} else if hive_type.starts_with("decimal(") {
302+
} else if hive_type.starts_with("map<")
303+
|| hive_type.starts_with("struct<")
304+
|| hive_type.starts_with("decimal(")
305+
{
307306
hive_type.to_string()
308307
} else {
309308
"string".to_string()

crates/k2i-core/src/iceberg/metadata_cache.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//! - Partition spec: 5 minutes TTL (rarely changes)
77
//! - Manifest entries: 1 minute TTL (for compaction decisions)
88
9-
use crate::Result;
109
use parking_lot::RwLock;
1110
use std::collections::HashMap;
1211
use std::sync::atomic::{AtomicU64, Ordering};

crates/k2i-core/src/iceberg/nessie.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
//! and reference (branch/tag) support.
99
1010
use crate::circuit_breaker::{CircuitBreaker, CircuitBreakerConfig};
11-
use crate::config::{CatalogType, CredentialType, IcebergConfig, NessieCatalogConfig};
11+
use crate::config::{CatalogType, CredentialType, IcebergConfig};
1212
use crate::iceberg::factory::{
13-
CatalogFactory, CatalogHealth, CatalogOperations, DataFileInfo, SchemaFieldInfo,
14-
SnapshotCommit, SnapshotCommitResult, TableInfo, TableSchema,
13+
CatalogFactory, CatalogHealth, CatalogOperations, SchemaFieldInfo, SnapshotCommit,
14+
SnapshotCommitResult, TableInfo, TableSchema,
1515
};
1616
use crate::iceberg::rest_api;
1717
use crate::{Error, IcebergError, Result};
@@ -93,11 +93,11 @@ struct CachedToken {
9393
impl NessieCatalogClient {
9494
/// Create a new Nessie catalog client.
9595
pub async fn new(config: &IcebergConfig, rest_uri: String) -> Result<Self> {
96-
let timeout = Duration::from_secs(config.rest.request_timeout_seconds.unwrap_or(30) as u64);
96+
let timeout = Duration::from_secs(config.rest.request_timeout_seconds.unwrap_or(30));
9797

9898
let http_client = Client::builder()
9999
.timeout(timeout)
100-
.pool_max_idle_per_host(config.catalog_manager.connection_pool_size as usize)
100+
.pool_max_idle_per_host(config.catalog_manager.connection_pool_size)
101101
.build()
102102
.map_err(|e| Error::Config(format!("Failed to create HTTP client: {}", e)))?;
103103

@@ -701,7 +701,7 @@ impl CatalogOperations for NessieCatalogClient {
701701
#[cfg(test)]
702702
mod tests {
703703
use super::*;
704-
use crate::config::ParquetCompression;
704+
use crate::config::{NessieCatalogConfig, ParquetCompression};
705705

706706
fn create_test_config() -> IcebergConfig {
707707
IcebergConfig {

crates/k2i-core/src/iceberg/schema_evolution.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ impl SchemaInference {
246246
}
247247

248248
// Check for numeric promotion
249-
let has_int = types.iter().any(|t| *t == IcebergType::Int);
250-
let has_long = types.iter().any(|t| *t == IcebergType::Long);
251-
let has_float = types.iter().any(|t| *t == IcebergType::Float);
252-
let has_double = types.iter().any(|t| *t == IcebergType::Double);
249+
let has_int = types.contains(&IcebergType::Int);
250+
let has_long = types.contains(&IcebergType::Long);
251+
let has_float = types.contains(&IcebergType::Float);
252+
let has_double = types.contains(&IcebergType::Double);
253253

254254
if has_double || (has_float && (has_int || has_long)) {
255255
return IcebergType::Double;
@@ -399,7 +399,7 @@ impl SchemaEvolution {
399399
name: field.name.clone(),
400400
field_type: field.field_type.to_iceberg_string().to_string(),
401401
required: false, // Always make new columns nullable for safety
402-
doc: Some(format!("Auto-added field from schema evolution")),
402+
doc: Some("Auto-added field from schema evolution".to_string()),
403403
})
404404
.collect()
405405
}

crates/k2i-core/src/iceberg/table_manager.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
99
use crate::config::{IcebergConfig, SchemaMismatchAction, TableManagementConfig};
1010
use crate::iceberg::factory::{CatalogOperations, SchemaFieldInfo, TableInfo, TableSchema};
11-
use crate::iceberg::metadata_cache::{
12-
CachedField, CachedPartitionField, CachedPartitionSpec, CachedSchema, MetadataCache,
13-
};
11+
use crate::iceberg::metadata_cache::{CachedField, CachedSchema, MetadataCache};
1412
use crate::iceberg::schema_evolution::{
1513
IcebergType, InferredField, SchemaEvolution, SchemaEvolutionConfig, SchemaEvolutionPlan,
1614
SchemaEvolver,
@@ -349,7 +347,7 @@ impl TableManager {
349347
}
350348

351349
// Fall back to catalog
352-
let table_info = self.load_table().await?;
350+
let _table_info = self.load_table().await?;
353351

354352
// Cache is already updated by load_table
355353
self.cache.get_schema().ok_or_else(|| {
@@ -589,10 +587,8 @@ impl Default for TableManagerBuilder {
589587
#[cfg(test)]
590588
mod tests {
591589
use super::*;
592-
use crate::config::{CatalogType, PartitionStrategy};
593-
use crate::iceberg::factory::{
594-
CatalogHealth, DataFileInfo, SnapshotCommit, SnapshotCommitResult,
595-
};
590+
use crate::config::CatalogType;
591+
use crate::iceberg::factory::{CatalogHealth, SnapshotCommit, SnapshotCommitResult};
596592
use async_trait::async_trait;
597593
use std::collections::HashMap;
598594

0 commit comments

Comments
 (0)