Skip to content

Commit bbdd8ff

Browse files
committed
Clippy and lints
Signed-off-by: Adam Gutglick <[email protected]>
1 parent 0c09f4e commit bbdd8ff

File tree

16 files changed

+67
-62
lines changed

16 files changed

+67
-62
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks/ddb-bench/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use vortex_bench::Opts;
1717
use vortex_bench::conversions::convert_parquet_to_vortex;
1818
use vortex_bench::create_benchmark;
1919
use vortex_bench::display::DisplayFormat;
20-
use vortex_bench::runner::BenchmarkRunner;
20+
use vortex_bench::runner::SqlBenchmarkRunner;
2121
use vortex_bench::runner::filter_queries;
2222
use vortex_bench::setup_logging_and_tracing;
2323

@@ -106,7 +106,7 @@ async fn main() -> anyhow::Result<()> {
106106
}
107107
}
108108

109-
let mut runner = BenchmarkRunner::new(
109+
let mut runner = SqlBenchmarkRunner::new(
110110
&*benchmark,
111111
Engine::DuckDB,
112112
args.formats.clone(),

benchmarks/df-bench/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use vortex_bench::Opts;
2424
use vortex_bench::conversions::convert_parquet_to_vortex;
2525
use vortex_bench::create_benchmark;
2626
use vortex_bench::display::DisplayFormat;
27-
use vortex_bench::runner::BenchmarkRunner;
27+
use vortex_bench::runner::SqlBenchmarkRunner;
2828
use vortex_bench::runner::filter_queries;
2929
use vortex_bench::setup_logging_and_tracing;
3030

@@ -129,7 +129,7 @@ async fn main() -> anyhow::Result<()> {
129129
}
130130
}
131131

132-
let mut runner = BenchmarkRunner::new(
132+
let mut runner = SqlBenchmarkRunner::new(
133133
&*benchmark,
134134
Engine::DataFusion,
135135
args.formats.clone(),

benchmarks/lance-bench/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ lance = { version = "0.39.0" }
1919
lance-encoding = { version = "0.39.0" }
2020

2121
anyhow = { workspace = true }
22-
arrow-array = { workspace = true }
2322
arrow-cast = { workspace = true }
2423
arrow-schema = { workspace = true }
2524
clap = { workspace = true, features = ["derive"] }
26-
datafusion = { workspace = true }
27-
datafusion-physical-plan = { workspace = true }
2825
futures = { workspace = true }
29-
parquet.workspace = true
26+
parquet = { workspace = true }
3027
tempfile = { workspace = true }
3128
tokio = { workspace = true, features = ["full"] }
3229
tracing.workspace = true

benchmarks/lance-bench/src/compress.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ use std::fs;
1414
use std::path::Path;
1515
use std::sync::Arc;
1616

17-
use arrow_array::RecordBatch;
18-
use arrow_array::RecordBatchIterator;
17+
use anyhow::anyhow;
1918
use arrow_schema::Schema;
2019
use futures::StreamExt;
2120
use lance::dataset::Dataset;
2221
use lance::dataset::WriteParams;
22+
use lance::deps::arrow_array::RecordBatch;
23+
use lance::deps::arrow_array::RecordBatchIterator;
2324
use lance_encoding::version::LanceFileVersion;
2425
use tempfile::TempDir;
2526

@@ -32,7 +33,9 @@ pub async fn lance_compress_write_only(
3233
schema: Arc<Schema>,
3334
dataset_path: &Path,
3435
) -> anyhow::Result<()> {
35-
let path = dataset_path.to_str().unwrap();
36+
let path = dataset_path
37+
.to_str()
38+
.ok_or_else(|| anyhow!("Failed to convert path to str"))?;
3639
let reader = RecordBatchIterator::new(batches.into_iter().map(Ok), schema);
3740
// Lance v2.1 fails on CMSProvider dataset.
3841
let write_params = WriteParams::with_storage_version(LanceFileVersion::V2_0);
@@ -110,7 +113,9 @@ pub async fn lance_compress_write(
110113
// Create a fixed subdirectory for decompression testing.
111114
let dataset_dir = temp_dir.path().join("dataset");
112115
fs::create_dir_all(&dataset_dir)?;
113-
let path = dataset_dir.to_str().unwrap();
116+
let path = dataset_dir
117+
.to_str()
118+
.ok_or_else(|| anyhow!("Failed to convert path to str"))?;
114119

115120
let reader = RecordBatchIterator::new(converted_batches.into_iter().map(Ok), converted_schema);
116121
// Lance v2.1 fails on CMSProvider dataset.

benchmarks/lance-bench/src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub async fn convert_parquet_to_lance<'p>(
118118
create_dir_all(&lance_dir).await?;
119119

120120
// Collect all Parquet files in the directory
121-
let parquet_files: Vec<_> = fs::read_dir(&parquet_dir)?
121+
let parquet_files: Vec<_> = fs::read_dir(parquet_dir)?
122122
.filter_map(|entry| entry.ok())
123123
.filter(|entry| {
124124
let path = entry.path();

benchmarks/lance-bench/src/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use std::sync::Arc;
66

77
use clap::Parser;
88
use clap::value_parser;
9-
use datafusion::arrow::array::RecordBatch;
10-
use datafusion::prelude::SessionContext;
11-
use datafusion_physical_plan::ExecutionPlan;
9+
1210
use lance::datafusion::LanceTableProvider;
1311
use lance::dataset::Dataset;
12+
use lance::deps::arrow_array::RecordBatch;
13+
use lance::deps::datafusion::physical_plan::ExecutionPlan;
14+
use lance::deps::datafusion::prelude::SessionContext;
1415
use lance_bench::convert::convert_parquet_to_lance;
1516
use tracing::info;
1617
use vortex_bench::Benchmark;
@@ -21,7 +22,7 @@ use vortex_bench::Opt;
2122
use vortex_bench::Opts;
2223
use vortex_bench::create_benchmark;
2324
use vortex_bench::display::DisplayFormat;
24-
use vortex_bench::runner::BenchmarkRunner;
25+
use vortex_bench::runner::SqlBenchmarkRunner;
2526
use vortex_bench::runner::filter_queries;
2627
use vortex_bench::setup_logging_and_tracing;
2728

@@ -86,7 +87,7 @@ async fn main() -> anyhow::Result<()> {
8687
// Convert Parquet to Lance format
8788
generate_lance_data(&*benchmark).await?;
8889

89-
let mut runner = BenchmarkRunner::new(
90+
let mut runner = SqlBenchmarkRunner::new(
9091
&*benchmark,
9192
Engine::DataFusion,
9293
vec![Format::Lance],
@@ -186,14 +187,13 @@ async fn generate_lance_data<B: Benchmark + ?Sized>(benchmark: &B) -> anyhow::Re
186187
// TPC-H/TPC-DS use {table}_ prefix, others may use the table name directly
187188
let file_prefix = benchmark
188189
.pattern(table.name, Format::Parquet)
189-
.map(|p| {
190+
.and_then(|p| {
190191
// Extract prefix from pattern like "customer_*.parquet" -> "customer_"
191192
let pattern_str = p.as_str();
192193
pattern_str
193194
.strip_suffix(&format!("*.{}", Format::Parquet.ext()))
194195
.map(|s| s.to_string())
195-
})
196-
.flatten();
196+
});
197197

198198
convert_parquet_to_lance(
199199
&parquet_dir,

vortex-bench/src/clickbench/clickbench_benchmark.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ impl Benchmark for ClickBenchBenchmark {
7474
None => Path::new(env!("CARGO_MANIFEST_DIR")).join("clickbench_queries.sql"),
7575
};
7676

77-
Ok(fs::read_to_string(queries_filepath)
78-
.unwrap()
77+
Ok(fs::read_to_string(queries_filepath)?
7978
.split(';')
8079
.map(|s| s.trim())
8180
.filter(|s| !s.is_empty())

vortex-bench/src/clickbench/clickbench_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl Flavor {
216216
let output_path = basepath.join(Format::Parquet.name()).join(format!("hits_{idx}.parquet"));
217217
let client = client.clone();
218218

219-
idempotent_async(output_path.clone(), move|output_path| async move {
219+
idempotent_async(output_path, move|output_path| async move {
220220
info!("Downloading file {idx}");
221221
let url = format!("https://pub-3ba949c0f0354ac18db1f0f14f0a2c52.r2.dev/clickbench/parquet_many/hits_{idx}.parquet");
222222
let response = retry_get(&client, url).await?;

vortex-bench/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,17 @@ impl Opts {
300300
self.inner.get(key).map(|s| s.as_str())
301301
}
302302

303+
#[expect(clippy::panic)]
303304
pub fn get_as<T>(&self, key: &str) -> Option<T>
304305
where
305306
T: FromStr,
306307
<T as FromStr>::Err: std::fmt::Debug,
307308
{
308-
self.inner.get(key).map(|v| v.parse().unwrap())
309+
self.inner.get(key).map(|v| {
310+
v.parse().unwrap_or_else(|_| {
311+
panic!("opts value {key} was parsed into an inappropriate type")
312+
})
313+
})
309314
}
310315
}
311316

0 commit comments

Comments
 (0)