Skip to content

Apache DataFusion SQL Query Engine

ARROW-11110: [Rust] [Datafusion] ExecutionContext.table should take immutable reference

Qingping Hou9f83f466b763
diff --git a/rust/datafusion/examples/simple_udaf.rs b/rust/datafusion/examples/simple_udaf.rs
index f5ec4bebb7..524a12513c 100644
--- a/rust/datafusion/examples/simple_udaf.rs
+++ b/rust/datafusion/examples/simple_udaf.rs
@@ -127,7 +127,7 @@ impl Accumulator for GeometricMean {
#[tokio::main]
async fn main() -> Result<()> {
- let mut ctx = create_context()?;
+ let ctx = create_context()?;
// here is where we define the UDAF. We also declare its signature:
let geometric_mean = create_udaf(
diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs
index ebfc8871d8..b4b715bacb 100644
--- a/rust/datafusion/src/execution/context.rs
+++ b/rust/datafusion/src/execution/context.rs
@@ -288,7 +288,7 @@ impl ExecutionContext {
/// Retrieves a DataFrame representing a table previously registered by calling the
/// register_table function. An Err result will be returned if no table has been
/// registered with the provided name.
- pub fn table(&mut self, table_name: &str) -> Result<Arc<dyn DataFrame>> {
+ pub fn table(&self, table_name: &str) -> Result<Arc<dyn DataFrame>> {
match self.state.lock().unwrap().datasources.get(table_name) {
Some(provider) => {
let schema = provider.schema();
@@ -710,7 +710,7 @@ mod tests {
async fn projection_on_table_scan() -> Result<()> {
let tmp_dir = TempDir::new()?;
let partition_count = 4;
- let mut ctx = create_ctx(&tmp_dir, partition_count)?;
+ let ctx = create_ctx(&tmp_dir, partition_count)?;
let table = ctx.table("test")?;
let logical_plan = LogicalPlanBuilder::from(&table.to_logical_plan())