Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion-examples/examples/simple_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn create_context() -> Result<SessionContext> {
/// 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]| {
Expand Down
14 changes: 7 additions & 7 deletions datafusion/core/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn VarProvider + Send + Sync>,
) {
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<str>,
options: NdJsonReadOptions<'_>,
) -> Result<Arc<DataFrame>> {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/physical_plan/file_format/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod tests {
file_compression_type: FileCompressionType,
store: Arc<dyn ObjectStore>,
) {
let mut ctx = SessionContext::new();
let ctx = SessionContext::new();
ctx.runtime_env()
.register_object_store("file", "", store.clone());
let filename = "1.json";
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions datafusion/core/tests/sql/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn scalar_udf() -> Result<()> {
],
)?;

let mut ctx = SessionContext::new();
let ctx = SessionContext::new();

ctx.register_batch("t", batch)?;

Expand Down Expand Up @@ -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))?;
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion datafusion/proto/src/bytes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ mod test {
scalar_fn,
);

let mut ctx = SessionContext::new();
let ctx = SessionContext::new();
ctx.register_udf(udf);

ctx
Expand Down
4 changes: 2 additions & 2 deletions datafusion/proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/proto/src/physical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down