You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/06/19 14:35:08 UTC
(datafusion) branch gh-readonly-queue/main/pr-23003-62b3b622367b1bd0af47cce61de320f906caf8fd created (now 88fb94d882)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-23003-62b3b622367b1bd0af47cce61de320f906caf8fd
in repository https://gitbox.apache.org/repos/asf/datafusion.git
at 88fb94d882 Add sorted TopK TPC-H benchmark target (#23003)
This branch includes the following new commits:
new 88fb94d882 Add sorted TopK TPC-H benchmark target (#23003)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org
(datafusion) 01/01: Add sorted TopK TPC-H benchmark target (#23003)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-23003-62b3b622367b1bd0af47cce61de320f906caf8fd
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 88fb94d88251a512694cc8b37ee09f53d6916160
Author: Geoffrey Claude <ge...@gmail.com>
AuthorDate: Fri Jun 19 16:34:45 2026 +0200
Add sorted TopK TPC-H benchmark target (#23003)
## Which issue does this PR close?
This PR adds a first-class benchmark target for an existing `sort-tpch`
mode.
## Rationale for this change
`dfbench sort-tpch` already supports TopK queries over input declared as
sorted with `--sorted --limit`, but `bench.sh` only exposed the unsorted
TopK wrapper as `topk_tpch`.
That made the sorted TopK path harder to run from the benchmark bot and
easier to miss during performance work. Adding `topk_sorted_tpch` gives
a named target for the sorted-input TopK case:
```bash
./benchmarks/bench.sh run topk_sorted_tpch
```
The new target uses `--limit 100` so it is the sorted counterpart to the
existing `topk_tpch` benchmark.
## What changes are included in this PR?
- Adds `topk_sorted_tpch` to the benchmark script help text.
- Reuses the existing TPC-H SF1 parquet data setup.
- Adds a `run_topk_sorted_tpch` wrapper around `dfbench sort-tpch
--sorted --limit 100`.
- Writes results to `run_topk_sorted_tpch.json`.
- Documents the new benchmark target in `benchmarks/README.md`.
## Are these changes tested?
Validated with:
```bash
bash -n benchmarks/bench.sh
CARGO_COMMAND=echo DATA_DIR=/tmp/df-topk-bench-data RESULTS_NAME=topk_sorted_tpch_smoke ./benchmarks/bench.sh run topk_sorted_tpch
git diff --check
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
```
The smoke run verified that the script dispatches to:
```bash
dfbench sort-tpch --iterations 5 --path ... --sorted --limit 100
```
## Are there any user-facing changes?
No engine or API behavior changes. This only adds a new opt-in benchmark
target.
---------
Co-authored-by: Gabriel <45...@users.noreply.github.com>
---
benchmarks/README.md | 20 ++++++++++++++++++--
benchmarks/bench.sh | 16 +++++++++++++++-
benchmarks/src/sort_tpch.rs | 4 ++--
3 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/benchmarks/README.md b/benchmarks/README.md
index d143de662e..53a43755f4 100644
--- a/benchmarks/README.md
+++ b/benchmarks/README.md
@@ -558,7 +558,15 @@ Test performance of end-to-end sort SQL queries. (While the `Sort` benchmark foc
Sort integration benchmark runs whole table sort queries on TPCH `lineitem` table, with different characteristics. For example, different number of sort keys, different sort key cardinality, different number of payload columns, etc.
-If the TPCH tables have been converted as sorted on their first column (see [Sorted Conversion](#sorted-conversion)), you can use the `--sorted` flag to indicate that the input data is pre-sorted, allowing DataFusion to leverage that order during query execution.
+The `--sorted` flag does not sort or rewrite the input files. It declares that the `lineitem` Parquet input is already sorted ascending by its first column (`l_orderkey`). DataFusion can then leverage that ordering during query execution.
+
+To generate the expected TPC-H SF=1 Parquet input for this benchmark, run:
+
+```bash
+./bench.sh data tpch
+```
+
+For the `lineitem` table used by `sort-tpch`, this uses `tpchgen-cli` to generate Parquet data that is already ordered by `l_orderkey`. If you use a different input directory, only pass `--sorted` when the `lineitem` files already have that ordering.
Additionally, an optional `--limit` flag is available for the sort benchmark. When specified, this flag appends a `LIMIT n` clause to the SQL query, effectively converting the query into a TopK query. Combining the `--sorted` and `--limit` options enables benchmarking of TopK queries on pre-sorted inputs.
@@ -578,7 +586,7 @@ See [`sort_tpch.rs`](src/sort_tpch.rs) for more details.
cargo run --release --bin dfbench -- sort-tpch -p './datafusion/benchmarks/data/tpch_sf1' -o '/tmp/sort_tpch.json' --query 2
```
-3. Run all queries as TopK queries on presorted data:
+3. Run all queries as TopK queries on already sorted data:
```bash
cargo run --release --bin dfbench -- sort-tpch --sorted --limit 10 -p './datafusion/benchmarks/data/tpch_sf1' -o '/tmp/sort_tpch.json'
@@ -598,6 +606,14 @@ In addition, topk_tpch is available from the bench.sh script:
./bench.sh run topk_tpch
```
+To benchmark TopK queries on TPC-H `lineitem` input ordered by `l_orderkey`, use:
+
+```bash
+./bench.sh run topk_sorted_tpch
+```
+
+This runs `dfbench sort-tpch --sorted --limit 100` through the benchmark script, using `--sorted` to declare the existing `l_orderkey` ordering.
+
## IMDB
Run Join Order Benchmark (JOB) on IMDB dataset.
diff --git a/benchmarks/bench.sh b/benchmarks/bench.sh
index 0e28beadf8..52b78c844a 100755
--- a/benchmarks/bench.sh
+++ b/benchmarks/bench.sh
@@ -99,6 +99,7 @@ tpcds: TPCDS inspired benchmark on Scale Factor (SF) 1 (~1GB),
sort_tpch: Benchmark of sorting speed for end-to-end sort queries on TPC-H dataset (SF=1)
sort_tpch10: Benchmark of sorting speed for end-to-end sort queries on TPC-H dataset (SF=10)
topk_tpch: Benchmark of top-k (sorting with limit) queries on TPC-H dataset (SF=1)
+topk_sorted_tpch: Benchmark of top-k queries on TPC-H lineitem ordered by l_orderkey (SF=1)
push_down_topk: Benchmark of ORDER BY ... LIMIT over outer joins on TPC-H dataset (SF=1) — exercises pushing TopK through a join
external_aggr: External aggregation benchmark on TPC-H dataset (SF=1)
wide_schema: Small-projection queries on a wide synthetic dataset (1024 cols × 256 files) — measures per-file metadata overhead
@@ -346,7 +347,7 @@ main() {
# same data as for tpch10
data_tpch "10" "parquet"
;;
- topk_tpch)
+ topk_tpch|topk_sorted_tpch)
# same data as for tpch
data_tpch "1" "parquet"
;;
@@ -577,6 +578,9 @@ main() {
topk_tpch)
run_topk_tpch
;;
+ topk_sorted_tpch)
+ run_topk_sorted_tpch
+ ;;
push_down_topk)
run_push_down_topk
;;
@@ -1506,6 +1510,16 @@ run_topk_tpch() {
$CARGO_COMMAND --bin dfbench -- sort-tpch --iterations 5 --path "${TPCH_DIR}" -o "${RESULTS_FILE}" --limit 100 ${QUERY_ARG} ${LATENCY_ARG}
}
+# Runs the sorted sort tpch integration benchmark with limit 100 (topk)
+run_topk_sorted_tpch() {
+ TPCH_DIR="${DATA_DIR}/tpch_sf1"
+ RESULTS_FILE="${RESULTS_DIR}/run_topk_sorted_tpch.json"
+ echo "RESULTS_FILE: ${RESULTS_FILE}"
+ echo "Running sorted topk tpch benchmark..."
+
+ $CARGO_COMMAND --bin dfbench -- sort-tpch --iterations 5 --path "${TPCH_DIR}" -o "${RESULTS_FILE}" --sorted --limit 100 ${QUERY_ARG} ${LATENCY_ARG}
+}
+
# Runs the nlj benchmark
run_nlj() {
RESULTS_FILE="${RESULTS_DIR}/nlj.json"
diff --git a/benchmarks/src/sort_tpch.rs b/benchmarks/src/sort_tpch.rs
index 338afec0e8..2182d1a383 100644
--- a/benchmarks/src/sort_tpch.rs
+++ b/benchmarks/src/sort_tpch.rs
@@ -64,8 +64,8 @@ pub struct RunOpt {
#[arg(short = 'm', long = "mem-table")]
mem_table: bool,
- /// Mark the first column of each table as sorted in ascending order.
- /// The tables should have been created with the `--sort` option for this to have any effect.
+ /// Declare that the first column of the input table is already sorted in ascending order.
+ /// This flag only attaches ordering metadata; it does not sort the input files.
#[arg(short = 't', long = "sorted")]
sorted: bool,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org