Skip to content

Commit 7fbbde2

Browse files
brunalJefffreyalamb
authored
Remove lint issues in parquet-related code. (#9375)
* CacheOptions: `use` in arrow/push_decoder/reader_builder/mod.rs was unused. But removing it triggers a doc complaint in array_reader.rs. I fix it by spelling out `CacheOptions` at one usage site. * ExtensionType import was unused in arrow/schema/extension.rs when compiling with default features. Only `use` it inside the feature-guarded code paths. * Prefix unused function arguments with `_`. * Some code in parquet/tests/arrow_reader/io/mod.rs is unused. As I lack knowledge of the context, I just add just add #[allow(dead_code)]. # Rationale for this change rust-analyzer bugs me about those unused symbols & co. --------- Co-authored-by: Jeffrey Vo <jeffrey.vo.australia@gmail.com> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
1 parent 7d16cd0 commit 7fbbde2

4 files changed

Lines changed: 32 additions & 12 deletions

File tree

parquet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ harness = false
233233

234234
[[bench]]
235235
name = "arrow_reader_clickbench"
236-
required-features = ["arrow", "async"]
236+
required-features = ["arrow", "async", "object_store"]
237237
harness = false
238238

239239
[[bench]]

parquet/src/arrow/push_decoder/reader_builder/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod filter;
2020

2121
use crate::DecodeResult;
2222
use crate::arrow::ProjectionMask;
23-
use crate::arrow::array_reader::{ArrayReaderBuilder, RowGroupCache};
23+
use crate::arrow::array_reader::{ArrayReaderBuilder, CacheOptions, RowGroupCache};
2424
use crate::arrow::arrow_reader::metrics::ArrowReaderMetrics;
2525
use crate::arrow::arrow_reader::selection::RowSelectionStrategy;
2626
use crate::arrow::arrow_reader::{
@@ -604,7 +604,7 @@ impl RowGroupReaderBuilder {
604604
let array_reader_builder = ArrayReaderBuilder::new(&row_group, &self.metrics)
605605
.with_parquet_metadata(&self.metadata);
606606
let array_reader = if let Some(cache_info) = cache_info.as_ref() {
607-
let cache_options = cache_info.builder().consumer();
607+
let cache_options: CacheOptions = cache_info.builder().consumer();
608608
array_reader_builder
609609
.with_cache_options(Some(&cache_options))
610610
.build_array_reader(self.fields.as_deref(), &self.projection)

parquet/src/arrow/schema/extension.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@
2222
//!
2323
//! Extension types are represented using the metadata from Arrow [`Field`]s
2424
//! with the key "ARROW:extension:name".
25+
//!
26+
//! Extension types are represented using the metadata from Arrow [`Field`]s
27+
//! with the key "ARROW:extension:name".
28+
//!
29+
//! [`ExtensionType`]: arrow_schema::extension::ExtensionType
2530
2631
use crate::basic::LogicalType;
2732
use crate::errors::ParquetError;
2833
use crate::schema::types::Type;
2934
use arrow_schema::Field;
30-
use arrow_schema::extension::ExtensionType;
3135

3236
/// Adds extension type metadata, if necessary, based on the Parquet field's
3337
/// [`LogicalType`]
@@ -36,39 +40,48 @@ use arrow_schema::extension::ExtensionType;
3640
/// Arrow DataType, and instead are represented by an Arrow ExtensionType.
3741
/// Extension types are attached to Arrow Fields via metadata.
3842
pub(crate) fn try_add_extension_type(
39-
mut arrow_field: Field,
43+
arrow_field: Field,
4044
parquet_type: &Type,
4145
) -> Result<Field, ParquetError> {
4246
let Some(parquet_logical_type) = parquet_type.get_basic_info().logical_type_ref() else {
4347
return Ok(arrow_field);
4448
};
45-
match parquet_logical_type {
49+
Ok(match parquet_logical_type {
4650
#[cfg(feature = "variant_experimental")]
4751
LogicalType::Variant { .. } => {
52+
let mut arrow_field = arrow_field;
4853
arrow_field.try_with_extension_type(parquet_variant_compute::VariantType)?;
54+
arrow_field
4955
}
5056
#[cfg(feature = "arrow_canonical_extension_types")]
5157
LogicalType::Uuid => {
58+
let mut arrow_field = arrow_field;
5259
arrow_field.try_with_extension_type(arrow_schema::extension::Uuid)?;
60+
arrow_field
5361
}
5462
#[cfg(feature = "arrow_canonical_extension_types")]
5563
LogicalType::Json => {
64+
let mut arrow_field = arrow_field;
5665
arrow_field.try_with_extension_type(arrow_schema::extension::Json::default())?;
66+
arrow_field
5767
}
5868
#[cfg(feature = "geospatial")]
5969
LogicalType::Geometry { crs } => {
6070
let md = parquet_geospatial::WkbMetadata::new(crs.as_deref(), None);
71+
let mut arrow_field = arrow_field;
6172
arrow_field.try_with_extension_type(parquet_geospatial::WkbType::new(Some(md)))?;
73+
arrow_field
6274
}
6375
#[cfg(feature = "geospatial")]
6476
LogicalType::Geography { crs, algorithm } => {
6577
let algorithm = algorithm.map(|a| a.try_as_edges()).transpose()?;
6678
let md = parquet_geospatial::WkbMetadata::new(crs.as_deref(), algorithm);
79+
let mut arrow_field = arrow_field;
6780
arrow_field.try_with_extension_type(parquet_geospatial::WkbType::new(Some(md)))?;
81+
arrow_field
6882
}
69-
_ => {}
70-
};
71-
Ok(arrow_field)
83+
_ => arrow_field,
84+
})
7285
}
7386

7487
/// Returns true if [`try_add_extension_type`] would add an extension type
@@ -97,6 +110,7 @@ pub(crate) fn has_extension_type(parquet_type: &Type) -> bool {
97110
/// Return the Parquet logical type to use for the specified Arrow Struct field, if any.
98111
#[cfg(feature = "variant_experimental")]
99112
pub(crate) fn logical_type_for_struct(field: &Field) -> Option<LogicalType> {
113+
use arrow_schema::extension::ExtensionType;
100114
use parquet_variant_compute::VariantType;
101115
// Check the name (= quick and cheap) and only try_extension_type if the name matches
102116
// to avoid unnecessary String allocations in ArrowError
@@ -151,6 +165,7 @@ pub(crate) fn logical_type_for_string(_field: &Field) -> Option<LogicalType> {
151165

152166
#[cfg(feature = "geospatial")]
153167
pub(crate) fn logical_type_for_binary(field: &Field) -> Option<LogicalType> {
168+
use arrow_schema::extension::ExtensionType;
154169
use parquet_geospatial::WkbType;
155170
use parquet_geospatial::WkbTypeHint;
156171

@@ -172,7 +187,7 @@ pub(crate) fn logical_type_for_binary(field: &Field) -> Option<LogicalType> {
172187
}
173188

174189
#[cfg(not(feature = "geospatial"))]
175-
pub(crate) fn logical_type_for_binary(field: &Field) -> Option<LogicalType> {
190+
pub(crate) fn logical_type_for_binary(_field: &Field) -> Option<LogicalType> {
176191
None
177192
}
178193

@@ -182,6 +197,6 @@ pub(crate) fn logical_type_for_binary_view(field: &Field) -> Option<LogicalType>
182197
}
183198

184199
#[cfg(not(feature = "geospatial"))]
185-
pub(crate) fn logical_type_for_binary_view(field: &Field) -> Option<LogicalType> {
200+
pub(crate) fn logical_type_for_binary_view(_field: &Field) -> Option<LogicalType> {
186201
None
187202
}

parquet/tests/arrow_reader/io/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ struct TestParquetFile {
244244
/// The operation log for IO operations performed on this file
245245
ops: Arc<OperationLog>,
246246
/// The (pre-parsed) parquet metadata for this file
247+
#[cfg(feature = "async")]
247248
parquet_metadata: Arc<ParquetMetaData>,
248249
}
249250

@@ -288,6 +289,7 @@ impl TestParquetFile {
288289
TestParquetFile {
289290
bytes,
290291
ops,
292+
#[cfg(feature = "async")]
291293
parquet_metadata,
292294
}
293295
}
@@ -302,7 +304,7 @@ impl TestParquetFile {
302304
&self.ops
303305
}
304306

305-
/// Return the parquet metadata for this file
307+
#[cfg(feature = "async")]
306308
fn parquet_metadata(&self) -> &Arc<ParquetMetaData> {
307309
&self.parquet_metadata
308310
}
@@ -477,10 +479,12 @@ enum LogEntry {
477479
/// Read the metadata of the parquet file
478480
ReadMetadata(Range<usize>),
479481
/// Access previously parsed metadata
482+
#[allow(dead_code)]
480483
GetProvidedMetadata,
481484
/// Read a single logical data object
482485
ReadData(ReadInfo),
483486
/// Read one or more logical data objects in a single operation
487+
#[allow(dead_code)]
484488
ReadMultipleData(Vec<LogEntry>),
485489
/// Not known where the read came from
486490
Unknown(Range<usize>),
@@ -572,6 +576,7 @@ impl OperationLog {
572576
/// accessed by the specified range
573577
///
574578
/// It behaves the same as [`add_entry_for_range`] but for multiple ranges.
579+
#[cfg(feature = "async")]
575580
fn add_entry_for_ranges<'a>(&self, ranges: impl IntoIterator<Item = &'a Range<usize>>) {
576581
let entries = ranges
577582
.into_iter()

0 commit comments

Comments
 (0)