-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-11557: [Rust][Datafusion] Add deregister_table #9445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
| /// | ||
|
|
@@ -723,6 +735,21 @@ mod tests { | |
| Ok(()) | ||
| } | ||
|
|
||
| #[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); | ||
|
Comment on lines
+747
to
+748
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about moving this to a separate test? This way, if something fails, it is more obvious what caused the failure.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do that. I hadn't done it originally because there is a fair amount of boilerplate to setting up a data source, but I agree that it makes sense to test is separately. |
||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn parallel_query_with_filter() -> Result<()> { | ||
| let tmp_dir = TempDir::new()?; | ||
|
|
@@ -1668,6 +1695,8 @@ mod tests { | |
| assert_eq!(a.value(i) + b.value(i), sum.value(i)); | ||
| } | ||
|
|
||
| ctx.deregister_table("t"); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you should be able to use
remove(name)here?