diff --git a/datafusion-examples/examples/simple_udf.rs b/datafusion-examples/examples/simple_udf.rs index 7f5fe4a2797c..c9044a87abc9 100644 --- a/datafusion-examples/examples/simple_udf.rs +++ b/datafusion-examples/examples/simple_udf.rs @@ -59,7 +59,7 @@ fn create_context() -> Result { /// In this example we will declare a single-type, single return type UDF that exponentiates f64, a^b #[tokio::main] async fn main() -> Result<()> { - let mut ctx = create_context()?; + let ctx = create_context()?; // First, declare the actual implementation of the calculation let pow = |args: &[ArrayRef]| { diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rs index 759cc79a8bf8..a73a95401da0 100644 --- a/datafusion/core/src/execution/context.rs +++ b/datafusion/core/src/execution/context.rs @@ -571,7 +571,7 @@ impl SessionContext { /// Registers a variable provider within this context. pub fn register_variable( - &mut self, + &self, variable_type: VarType, provider: Arc, ) { @@ -588,7 +588,7 @@ impl SessionContext { /// /// `SELECT MY_FUNC(x)...` will look for a function named `"my_func"` /// `SELECT "my_FUNC"(x)` will look for a function named `"my_FUNC"` - pub fn register_udf(&mut self, f: ScalarUDF) { + pub fn register_udf(&self, f: ScalarUDF) { self.state .write() .scalar_functions @@ -602,7 +602,7 @@ impl SessionContext { /// /// `SELECT MY_UDAF(x)...` will look for an aggregate named `"my_udaf"` /// `SELECT "my_UDAF"(x)` will look for an aggregate named `"my_UDAF"` - pub fn register_udaf(&mut self, f: AggregateUDF) { + pub fn register_udaf(&self, f: AggregateUDF) { self.state .write() .aggregate_functions @@ -638,7 +638,7 @@ impl SessionContext { /// Creates a [`DataFrame`] for reading an Json data source. pub async fn read_json( - &mut self, + &self, table_path: impl AsRef, options: NdJsonReadOptions<'_>, ) -> Result> { @@ -2085,7 +2085,7 @@ mod tests { async fn create_variable_expr() -> Result<()> { let tmp_dir = TempDir::new()?; let partition_count = 4; - let mut ctx = create_ctx(&tmp_dir, partition_count).await?; + let ctx = create_ctx(&tmp_dir, partition_count).await?; let variable_provider = test::variable::SystemVar::new(); ctx.register_variable(VarType::System, Arc::new(variable_provider)); @@ -2143,7 +2143,7 @@ mod tests { #[tokio::test] async fn case_sensitive_identifiers_user_defined_functions() -> Result<()> { - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.register_table("t", test::table_with_sequence(1, 1).unwrap()) .unwrap(); @@ -2184,7 +2184,7 @@ mod tests { #[tokio::test] async fn case_sensitive_identifiers_user_defined_aggregates() -> Result<()> { - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.register_table("t", test::table_with_sequence(1, 1).unwrap()) .unwrap(); diff --git a/datafusion/core/src/physical_plan/file_format/json.rs b/datafusion/core/src/physical_plan/file_format/json.rs index fe5db9d860b6..d8c6b64121b3 100644 --- a/datafusion/core/src/physical_plan/file_format/json.rs +++ b/datafusion/core/src/physical_plan/file_format/json.rs @@ -306,7 +306,7 @@ mod tests { file_compression_type: FileCompressionType, store: Arc, ) { - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.runtime_env() .register_object_store("file", "", store.clone()); let filename = "1.json"; diff --git a/datafusion/core/tests/sql/mod.rs b/datafusion/core/tests/sql/mod.rs index 1e1307672394..1075041c2498 100644 --- a/datafusion/core/tests/sql/mod.rs +++ b/datafusion/core/tests/sql/mod.rs @@ -138,7 +138,7 @@ where } fn create_ctx() -> SessionContext { - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); // register a custom UDF ctx.register_udf(create_udf( diff --git a/datafusion/core/tests/sql/udf.rs b/datafusion/core/tests/sql/udf.rs index 37a869f933a4..a5e2f06a5438 100644 --- a/datafusion/core/tests/sql/udf.rs +++ b/datafusion/core/tests/sql/udf.rs @@ -53,7 +53,7 @@ async fn scalar_udf() -> Result<()> { ], )?; - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.register_batch("t", batch)?; @@ -138,7 +138,7 @@ async fn simple_udaf() -> Result<()> { vec![Arc::new(Int32Array::from_slice([4, 5]))], )?; - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); let provider = MemTable::try_new(Arc::new(schema), vec![vec![batch1], vec![batch2]])?; ctx.register_table("t", Arc::new(provider))?; @@ -205,7 +205,7 @@ fn udaf_as_window_func() -> Result<()> { Arc::new(vec![DataType::Int32]), ); - let mut context = SessionContext::new(); + let context = SessionContext::new(); context.register_table( "my_table", Arc::new(datafusion::datasource::empty::EmptyTable::new(Arc::new( diff --git a/datafusion/proto/src/bytes/mod.rs b/datafusion/proto/src/bytes/mod.rs index 005b76a567b8..1eb946bd5099 100644 --- a/datafusion/proto/src/bytes/mod.rs +++ b/datafusion/proto/src/bytes/mod.rs @@ -553,7 +553,7 @@ mod test { scalar_fn, ); - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.register_udf(udf); ctx diff --git a/datafusion/proto/src/lib.rs b/datafusion/proto/src/lib.rs index 7847ae06815b..6d34b69f3897 100644 --- a/datafusion/proto/src/lib.rs +++ b/datafusion/proto/src/lib.rs @@ -1256,7 +1256,7 @@ mod roundtrip_tests { filter: Some(Box::new(lit(true))), }; - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.register_udaf(dummy_agg); roundtrip_expr_test(test_expr, ctx); @@ -1281,7 +1281,7 @@ mod roundtrip_tests { args: vec![lit("")], }; - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.register_udf(udf); roundtrip_expr_test(test_expr, ctx); diff --git a/datafusion/proto/src/physical_plan/mod.rs b/datafusion/proto/src/physical_plan/mod.rs index f890c3ece620..f6b6a0bfe84b 100644 --- a/datafusion/proto/src/physical_plan/mod.rs +++ b/datafusion/proto/src/physical_plan/mod.rs @@ -1558,7 +1558,7 @@ mod roundtrip_tests { let project = ProjectionExec::try_new(vec![(Arc::new(expr), "a".to_string())], input)?; - let mut ctx = SessionContext::new(); + let ctx = SessionContext::new(); ctx.register_udf(udf);