Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Feb 14, 2025

Which issue does this PR close?

Rationale for this change

This was something I noticed while trying to upgrade InfluxDB IOx to use the new APIs introduced in #14224

I would like to make it easier when someone using these APIs upgrades

What changes are included in this PR?

  1. Rename new_exec->build`
  2. Change it to take self rather than force a clone

Are these changes tested?

Are there any user-facing changes?

There are some changes to APIs that are not yet released

@github-actions github-actions bot added core Core DataFusion crate substrait Changes to the substrait crate proto Related to proto crate labels Feb 14, 2025

// Finally, put it all together into a DataSourceExec
Ok(file_scan_config.new_exec())
Ok(file_scan_config.build())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is basically the change -- use build rather than new_exec which I think is more consistent with the style of code in the rest of this crate (and the Rust builder style in general)

) -> Result<Arc<dyn ExecutionPlan>> {
conf = conf.with_source(Arc::new(ArrowSource::default()));
Ok(conf.new_exec())
Ok(conf.with_source(Arc::new(ArrowSource::default())).build())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dive by cleanup to avoid mut and make it more concise

// This process can be moved into CsvExec, but it would be an overlap of their responsibility.
Ok(all_alias_free_columns(projection.expr()).then(|| {
let mut file_scan = self.clone();
let file_scan = self.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously calling new_exec always cloned. Now it is only cloned when necessary

pub fn new_exec(&self) -> Arc<DataSourceExec> {
Arc::new(DataSourceExec::new(Arc::new(self.clone())))
/// Returns a new [`DataSourceExec`] to scan the files specified by this config
pub fn build(self) -> Arc<DataSourceExec> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed and changed to take self rather than &self

/// PartitionedFile::new("file2.parquet", 56),
/// PartitionedFile::new("file3.parquet", 78),
/// ]);
/// // create an execution plan from the config
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also tried to add some docs that could make build easier to discover

Copy link
Member

@xudong963 xudong963 left a comment

Choose a reason for hiding this comment

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

Nice 🧹

@xudong963 xudong963 merged commit a2e6c90 into apache:main Feb 15, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate proto Related to proto crate substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants