Skip to content
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

Minor: Add Extensions::new() #5676

Merged
merged 2 commits into from
Mar 22, 2023
Merged

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Mar 21, 2023

Which issue does this PR close?

N/A

Rationale for this change

@andygrove reported on [ASF Slack](https://the-asf.slack.com/archives/C01QUFS30TD/p1679408811522469

I am trying to upgrade Ray SQL to DataFusion 20, and running into problems trying to create the new Extensions param to TaskContext::try_new
The struct is defined as:
#[derive(Debug, Default, Clone)]
pub struct Extensions(BTreeMap<&'static str, ExtensionBox>);

I am hitting this error:
error[E0423]: cannot initialize a tuple struct which contains private fields
--> src/context.rs:177:13
|
177 | Extensions(BTreeMap::new())
| ^^^^^^^^^^
|
note: constructor is not visible here due to private fields

Am I missing something obvious here, or is it no longer possible to create TaskContext outside of the core project?

Turns out the answer was Extensions::default:

11:10 AM
ah, nm, ... `
Extensions::default()

What changes are included in this PR?

Add an Extensions::new() which is the idiomatic way to create "new" objects in Rust

Are these changes tested?

Yes -- updated existing tests

Are there any user-facing changes?

Slightly better ergonomics and discoverability

@github-actions github-actions bot added the core Core DataFusion crate label Mar 21, 2023
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alamb. That is certainly easier to find.

@jackwener jackwener merged commit 8eaa292 into apache:main Mar 22, 2023
@alamb alamb deleted the alamb/new_extensions branch March 22, 2023 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants