Skip to content

Commit

Permalink
refactor: remove more unused mut
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Aug 7, 2024
1 parent 12462a0 commit 188f378
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions datafusion/core/benches/filter_query_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,25 @@ fn criterion_benchmark(c: &mut Criterion) {
let batch_size = 4096; // 2^12

c.bench_function("filter_array", |b| {
let mut ctx = create_context(array_len, batch_size).unwrap();
b.iter(|| block_on(query(&mut ctx, "select f32, f64 from t where f32 >= f64")))
let ctx = create_context(array_len, batch_size).unwrap();
b.iter(|| block_on(query(&ctx, "select f32, f64 from t where f32 >= f64")))
});

c.bench_function("filter_scalar", |b| {
let mut ctx = create_context(array_len, batch_size).unwrap();
let ctx = create_context(array_len, batch_size).unwrap();
b.iter(|| {
block_on(query(
&mut ctx,
&ctx,
"select f32, f64 from t where f32 >= 250 and f64 > 250",
))
})
});

c.bench_function("filter_scalar in list", |b| {
let mut ctx = create_context(array_len, batch_size).unwrap();
let ctx = create_context(array_len, batch_size).unwrap();
b.iter(|| {
block_on(query(
&mut ctx,
&ctx,
"select f32, f64 from t where f32 in (10, 20, 30, 40)",
))
})
Expand Down
14 changes: 7 additions & 7 deletions datafusion/core/src/dataframe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ impl DataFrame {
/// # #[tokio::main]
/// # async fn main() -> Result<()> {
/// # use datafusion_common::ScalarValue;
/// let mut ctx = SessionContext::new();
/// let ctx = SessionContext::new();
/// # ctx.register_csv("example", "tests/data/example.csv", CsvReadOptions::new()).await?;
/// let results = ctx
/// .sql("SELECT a FROM example WHERE b = $1")
Expand Down Expand Up @@ -2649,8 +2649,8 @@ mod tests {

#[tokio::test]
async fn registry() -> Result<()> {
let mut ctx = SessionContext::new();
register_aggregate_csv(&mut ctx, "aggregate_test_100").await?;
let ctx = SessionContext::new();
register_aggregate_csv(&ctx, "aggregate_test_100").await?;

// declare the udf
let my_fn: ScalarFunctionImplementation =
Expand Down Expand Up @@ -2783,8 +2783,8 @@ mod tests {

/// Create a logical plan from a SQL query
async fn create_plan(sql: &str) -> Result<LogicalPlan> {
let mut ctx = SessionContext::new();
register_aggregate_csv(&mut ctx, "aggregate_test_100").await?;
let ctx = SessionContext::new();
register_aggregate_csv(&ctx, "aggregate_test_100").await?;
Ok(ctx.sql(sql).await?.into_unoptimized_plan())
}

Expand Down Expand Up @@ -3147,9 +3147,9 @@ mod tests {
"datafusion.sql_parser.enable_ident_normalization".to_owned(),
"false".to_owned(),
)]))?;
let mut ctx = SessionContext::new_with_config(config);
let ctx = SessionContext::new_with_config(config);
let name = "aggregate_test_100";
register_aggregate_csv(&mut ctx, name).await?;
register_aggregate_csv(&ctx, name).await?;
let df = ctx.table(name);

let df = df
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/tests/user_defined/user_defined_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ async fn topk_query() -> Result<()> {
#[tokio::test]
// Run EXPLAIN PLAN and show the plan was in fact rewritten
async fn topk_plan() -> Result<()> {
let mut ctx = setup_table(make_topk_context()).await?;
let ctx = setup_table(make_topk_context()).await?;

let mut expected = ["| logical_plan after topk | TopK: k=3 |",
"| | TableScan: sales projection=[customer_id,revenue] |"].join("\n");

let explain_query = format!("EXPLAIN VERBOSE {QUERY}");
let actual_output = exec_sql(&mut ctx, &explain_query).await?;
let actual_output = exec_sql(&ctx, &explain_query).await?;

// normalize newlines (output on windows uses \r\n)
let mut actual_output = actual_output.replace("\r\n", "\n");
Expand Down
4 changes: 3 additions & 1 deletion datafusion/proto/tests/cases/roundtrip_logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ async fn roundtrip_logical_plan_copy_to_parquet() -> Result<()> {
// Set specific Parquet format options
let mut key_value_metadata = HashMap::new();
key_value_metadata.insert("test".to_string(), Some("test".to_string()));
parquet_format.key_value_metadata = key_value_metadata.clone();
parquet_format
.key_value_metadata
.clone_from(&key_value_metadata);

parquet_format.global.allow_single_file_parallelism = false;
parquet_format.global.created_by = "test".to_string();
Expand Down

0 comments on commit 188f378

Please sign in to comment.