Skip to content

Commit c2fc9cd

Browse files
committed
chore: remove stale #[allow(dead_code)] from expr visitors and spec
Part of #2559. - expr/visitors: gate strict_metrics_evaluator and strict_projection behind cfg(test) — they are only exercised by their own unit tests until delete/overwrite support starts using them — and drop the per-item allows. - spec/manifest/writer: add_delete_entry and add_existing_entry are only called from unit tests, so mark them cfg(test) instead of allow(dead_code). - spec/snapshot: remove the unused Snapshot::log() helper. - spec/values/decimal_utils: decimal_new is a test-only helper, so mark it cfg(test). Co-authored-by: Isaac
1 parent c527d7f commit c2fc9cd

6 files changed

Lines changed: 6 additions & 27 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ pub(crate) mod page_index_evaluator;
2424
pub(crate) mod predicate_visitor;
2525
pub(crate) mod rewrite_not;
2626
pub(crate) mod row_group_metrics_evaluator;
27+
// TODO: Remove the `cfg(test)` once delete/overwrite support starts using the strict visitors.
28+
#[cfg(test)]
2729
pub(crate) mod strict_metrics_evaluator;
30+
#[cfg(test)]
2831
pub(crate) mod strict_projection;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ use crate::expr::{BoundPredicate, BoundReference};
2222
use crate::spec::{DataFile, Datum};
2323
use crate::{Error, ErrorKind, Result};
2424

25-
#[allow(dead_code)]
2625
const ROWS_MUST_MATCH: Result<bool> = Ok(true);
27-
#[allow(dead_code)]
2826
const ROWS_MIGHT_NOT_MATCH: Result<bool> = Ok(false);
2927

30-
#[allow(dead_code)]
3128
/// Evaluates an `Expression` on a `DataFile` to test whether all rows in the file match.
3229
///
3330
/// This evaluation is strict: it returns true if all rows in a file must match the expression.
@@ -41,7 +38,6 @@ pub(crate) struct StrictMetricsEvaluator<'a> {
4138
}
4239

4340
impl<'a> StrictMetricsEvaluator<'a> {
44-
#[allow(dead_code)]
4541
fn new(data_file: &'a DataFile) -> Self {
4642
StrictMetricsEvaluator { data_file }
4743
}
@@ -50,7 +46,6 @@ impl<'a> StrictMetricsEvaluator<'a> {
5046
/// provided [`DataFile`]'s metrics. Used by [`TableScan`] to
5147
/// see if this `DataFile` contains data that could match
5248
/// the scan's filter.
53-
#[allow(dead_code)]
5449
pub(crate) fn eval(filter: &'a BoundPredicate, data_file: &'a DataFile) -> crate::Result<bool> {
5550
if data_file.record_count == 0 {
5651
return ROWS_MUST_MATCH;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,11 @@ use crate::expr::{BoundPredicate, BoundReference, Predicate};
2424
use crate::spec::{Datum, PartitionField, PartitionSpecRef};
2525
use crate::{Error, ErrorKind};
2626

27-
// # TODO
28-
// Remove this after delete support
29-
#[allow(dead_code)]
3027
pub(crate) struct StrictProjection {
3128
partition_spec: PartitionSpecRef,
3229
cached_parts: HashMap<i32, Vec<PartitionField>>,
3330
}
3431

35-
#[allow(dead_code)]
3632
impl StrictProjection {
3733
pub(crate) fn new(partition_spec: PartitionSpecRef) -> Self {
3834
Self {

crates/iceberg/src/spec/manifest/writer.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,7 @@ impl ManifestWriter {
336336
/// Add a delete manifest entry. This method will update following status of the entry:
337337
/// - Update the entry status to `Deleted`
338338
/// - Set the snapshot id to the current snapshot id
339-
///
340-
/// # TODO
341-
/// Remove this allow later
342-
#[allow(dead_code)]
339+
#[cfg(test)]
343340
pub(crate) fn add_delete_entry(&mut self, mut entry: ManifestEntry) -> Result<()> {
344341
self.check_data_file(&entry.data_file)?;
345342
entry.status = ManifestStatus::Deleted;
@@ -371,10 +368,7 @@ impl ManifestWriter {
371368

372369
/// Add an existing manifest entry. This method will update following status of the entry:
373370
/// - Update the entry status to `Existing`
374-
///
375-
/// # TODO
376-
/// Remove this allow later
377-
#[allow(dead_code)]
371+
#[cfg(test)]
378372
pub(crate) fn add_existing_entry(&mut self, mut entry: ManifestEntry) -> Result<()> {
379373
self.check_data_file(&entry.data_file)?;
380374
entry.status = ManifestStatus::Existing;

crates/iceberg/src/spec/snapshot.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use chrono::{DateTime, Utc};
2525
use serde::{Deserialize, Serialize};
2626
use typed_builder::TypedBuilder;
2727

28-
use super::table_metadata::SnapshotLog;
2928
use crate::error::{Result, timestamp_ms_to_utc};
3029
use crate::spec::{SchemaId, SchemaRef, TableMetadata};
3130
use crate::{Error, ErrorKind};
@@ -193,14 +192,6 @@ impl Snapshot {
193192
}
194193
}
195194

196-
#[allow(dead_code)]
197-
pub(crate) fn log(&self) -> SnapshotLog {
198-
SnapshotLog {
199-
timestamp_ms: self.timestamp_ms,
200-
snapshot_id: self.snapshot_id,
201-
}
202-
}
203-
204195
/// The row-id of the first newly added row in this snapshot. All rows added in this snapshot will
205196
/// have a row-id assigned to them greater than this value. All rows with a row-id less than this
206197
/// value were created in a snapshot that was added to the table (but not necessarily committed to

crates/iceberg/src/spec/values/decimal_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn try_decimal_from_i128_with_scale(mantissa: i128, scale: u32) -> Result<De
8383
/// Create a D128 from i64 mantissa and scale.
8484
///
8585
/// This is equivalent to rust_decimal's `Decimal::new`.
86-
#[allow(dead_code)]
86+
#[cfg(test)]
8787
pub fn decimal_new(mantissa: i64, scale: u32) -> Decimal {
8888
decimal_from_i128_with_scale(mantissa as i128, scale)
8989
}

0 commit comments

Comments
 (0)