-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Make SessionContext::enable_url_table consume self #12573
Conversation
@@ -64,7 +64,7 @@ async fn main() -> Result<()> { | |||
df.show().await?; | |||
|
|||
// dynamic query by the file path | |||
ctx.enable_url_table(); | |||
let ctx = ctx.enable_url_table(); |
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.
this example actually has the exact same bug I hit in #12551 -- namely the returned ctx has the table enabled, not the current one.
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.
Thanks for reminding this bug!
pub fn enable_url_table(&self) -> Self { | ||
let state_ref = self.state(); | ||
pub fn enable_url_table(self) -> Self { | ||
let current_catalog_list = Arc::clone(self.state.read().catalog_list()); |
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.
this avoids copying the entire state just to copy the catalog list
Arc::clone(&factory) as Arc<dyn UrlTableFactory>, | ||
)); | ||
let new_state = SessionStateBuilder::new_from_existing(self.state()) | ||
let ctx: SessionContext = self |
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.
This is likely just my obsession with trying to have clear Builder style APIs, but I think it reads more clearly here to to back and forth between the types
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.
Thanks @alamb. Overall looks good to me 👍
@@ -64,7 +64,7 @@ async fn main() -> Result<()> { | |||
df.show().await?; | |||
|
|||
// dynamic query by the file path | |||
ctx.enable_url_table(); | |||
let ctx = ctx.enable_url_table(); |
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.
Thanks for reminding this bug!
Thanks @andygrove and @goldmedal |
Which issue does this PR close?
Fixes #12551
Rationale for this change
As described on #12551 the current non consuming API was confusing and caused silently ignored bugs
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?