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

Simplify file struct abstractions #1120

Merged
merged 2 commits into from
Oct 17, 2021
Merged

Conversation

rdettai
Copy link
Contributor

@rdettai rdettai commented Oct 15, 2021

Rationale for this change

Currently we have many abstractions that sound very similar: PartitionedFile, FilePartition, ParquetPartition. This is an attempt to simplify the code by removing FilePartition and ParquetPartition.

What changes are included in this PR?

Are there any user-facing changes?

FilePartition was publicly accessible but not really part of the public API

@github-actions github-actions bot added ballista datafusion Changes in the datafusion crate labels Oct 15, 2021
Comment on lines -86 to -96
/// Represents one partition of a Parquet data set and this currently means one Parquet file.
///
/// In the future it would be good to support subsets of files based on ranges of row groups
/// so that we can better parallelize reads of large files across available cores (see
/// [ARROW-10995](https://issues.apache.org/jira/browse/ARROW-10995)).
///
/// We may also want to support reading Parquet files that are partitioned based on a key and
/// in this case we would want this partition struct to represent multiple files for a given
/// partition key (see [ARROW-11019](https://issues.apache.org/jira/browse/ARROW-11019)).
#[derive(Debug, Clone)]
pub struct ParquetPartition {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These comments were mostly outdated and the other features mentioned are now planned in the ListingTable provider

.iter()
.map(|fp| fp.file_partition.files.as_slice())
.collect()
pub fn file_groups(&self) -> &[Vec<PartitionedFile>] {
Copy link
Contributor Author

@rdettai rdettai Oct 15, 2021

Choose a reason for hiding this comment

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

We replace partitions with file_groups to try decrease the overuse of the term "partition" which represents different (yet similar 😅) things in different contexts:

  • on the listing table side, a partition refer to a "hive partition", that is to say a set of files grouped into a folder because they share a common attribute
  • on the execution plan side, a partition is a unit of parallelism. Files are grouped together to provide a good workload for one thread/executor.

@houqp houqp added the enhancement New feature or request label Oct 16, 2021
@houqp
Copy link
Member

houqp commented Oct 16, 2021

cc @yjshen

/// Execution plan for scanning one or more Parquet partitions
#[derive(Debug, Clone)]
pub struct ParquetExec {
object_store: Arc<dyn ObjectStore>,
/// Parquet partitions to read
partitions: Vec<ParquetPartition>,
/// List of parquet files, grouped by output partition
Copy link
Member

Choose a reason for hiding this comment

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

"output partition" is vague here.
file_group, i.e. Vec<PartitionedFile>, is the unit of parallelism and will be processed by one single executor/thread.

Copy link
Member

Choose a reason for hiding this comment

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

are you suggesting us coming up with a name that's semantically closer to concurrency?

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 was referring to the ExecutionPlan.output_partitioning(). Let me change this for something slightly more explicit 🙂 (I'll try to update this later today)

Copy link
Member

Choose a reason for hiding this comment

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

Yes. I think we can rephrase this line to avoid the ambiguity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Member

Choose a reason for hiding this comment

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

Lgtm

@rdettai
Copy link
Contributor Author

rdettai commented Oct 17, 2021

Thank you all for your reviews 😃, eager to see this merged so that I can create the PR for #1122

@houqp houqp merged commit 161fcd8 into apache:master Oct 17, 2021
@houqp
Copy link
Member

houqp commented Oct 17, 2021

Thanks @rdettai !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants