You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/02/12 11:15:39 UTC
[arrow] branch master updated: ARROW-11557: [Rust][Datafusion] Add
deregister_table
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new d6fee75 ARROW-11557: [Rust][Datafusion] Add deregister_table
d6fee75 is described below
commit d6fee755da3c27f159f01293ed035d841f5f4c03
Author: Marc Prud'hommeaux <ma...@prux.org>
AuthorDate: Fri Feb 12 06:14:53 2021 -0500
ARROW-11557: [Rust][Datafusion] Add deregister_table
https://issues.apache.org/jira/browse/ARROW-11557
Table de-registration, as discussed at https://lists.apache.org/thread.html/r0b3bc62a720c204c5bbe26d8157963276f7d61c05fcbad7eaf2ae9ff%40%3Cdev.arrow.apache.org%3E
Closes #9445 from marcprux/patch-4
Authored-by: Marc Prud'hommeaux <ma...@prux.org>
Signed-off-by: Andrew Lamb <an...@nerdnetworks.org>
---
rust/datafusion/src/execution/context.rs | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs
index a6fd020..2977d98 100644
--- a/rust/datafusion/src/execution/context.rs
+++ b/rust/datafusion/src/execution/context.rs
@@ -287,6 +287,18 @@ impl ExecutionContext {
.insert(name.to_string(), provider.into());
}
+ /// Deregisters the named table.
+ ///
+ /// Returns true if the table was successfully de-reregistered.
+ pub fn deregister_table(&mut self, name: &str) -> bool {
+ self.state
+ .lock()
+ .unwrap()
+ .datasources
+ .remove(&name.to_string())
+ .is_some()
+ }
+
/// Retrieves a DataFrame representing a table previously registered by calling the
/// register_table function.
///
@@ -724,6 +736,21 @@ mod tests {
}
#[tokio::test]
+ async fn register_deregister() -> Result<()> {
+ let tmp_dir = TempDir::new()?;
+ let partition_count = 4;
+ let mut ctx = create_ctx(&tmp_dir, partition_count)?;
+
+ let provider = test::create_table_dual();
+ ctx.register_table("dual", provider);
+
+ assert_eq!(ctx.deregister_table("dual"), true);
+ assert_eq!(ctx.deregister_table("dual"), false);
+
+ Ok(())
+ }
+
+ #[tokio::test]
async fn parallel_query_with_filter() -> Result<()> {
let tmp_dir = TempDir::new()?;
let partition_count = 4;
@@ -1668,6 +1695,8 @@ mod tests {
assert_eq!(a.value(i) + b.value(i), sum.value(i));
}
+ ctx.deregister_table("t");
+
Ok(())
}