apache / apache/datafusion

Automatically detect and use "is the data sorted" information in parquet file metadata

Open
#4,177 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

**Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
Suggested by @crepererum in https://github.com/apache/arrow-datafusion/issues/4169#issuecomment-1311347788

Some systems such as IOx, store parquet files in a particular sorted order, and then uses the fact the data is sorted for a variety of sort related optimizations.

Storing sorted data in parquet is often a key performance technique as it "clusters" data in interesting ways than can make predicate evaluation and other query techniques faster.

The `BasicEnforcement` rule added in https://github.com/apache/arrow-datafusion/pull/4122 by @mingmwang allows DataFusion to take advantage of known information about the sort order.

One contrived example is if your parquet file is sorted by `price` and your query is `select * from data order by price limit 10` datafusion can avoid scanning the entire file

Another more interesting example could be using sorted order to reorder pushdown filters or using a sort-merge-join without actually sorting

**Describe the solution you'd like**
- [x] https://github.com/apache/arrow-rs/issues/3090
- [ ] Detect and use this sorted information when creating a ListingTable that reads from parquet files

**Describe alternatives you've considered**
Don't do it

**Additional context**

Here is a ticket that tracks allowing users of DataFusion to manually specify the sort order: https://github.com/apache/arrow-datafusion/issues/4169

Contributor guide

Open the contributing guide

Research direction

Start by reading the ListingTable parquet creation path and the linked manual sort-order issue, #4169. Trace how parquet metadata reaches DataFusion's planning rules and determine how detected ordering should be represented and consumed. Done means parquet sort information is detected for ListingTable scans and is available to the relevant sort-related optimizations, with coverage for the supported metadata cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, databases, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.