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/08/02 09:58:31 UTC
(datafusion) 01/01: WindowTopN dense_rank benchmark (#24050)
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-24050-f3a895ffb2c26c32532cead6a597684e4b8857e7
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 60d9b67ec9428cac3e5b7ec7f25774f797063b65
Author: Subham Singhal <Su...@users.noreply.github.com>
AuthorDate: Sun Aug 2 15:28:08 2026 +0530
WindowTopN dense_rank benchmark (#24050)
dense_rank benchmark
---
benchmarks/queries/h2o/window.sql | 50 +++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/benchmarks/queries/h2o/window.sql b/benchmarks/queries/h2o/window.sql
index 37df0a28ae..ece2c75abd 100644
--- a/benchmarks/queries/h2o/window.sql
+++ b/benchmarks/queries/h2o/window.sql
@@ -196,3 +196,53 @@ SELECT pk, largest_v2 FROM (
RANK() OVER (PARTITION BY (id3 % 100000) ORDER BY v2 DESC) AS rk_v2
FROM large WHERE v2 IS NOT NULL
) sub_query WHERE rk_v2 <= 2;
+
+-- Window Top-N (DENSE_RANK top-2 per partition, ~100 partitions)
+-- The DENSE_RANK queries below mirror the RANK cardinality sweep above.
+-- DENSE_RANK semantics keep every row whose ORDER BY value is among the
+-- K distinct-greatest values in the partition, so total kept per partition
+-- is unbounded in rows-per-distinct-value — exercises PartitionedTopKDenseRank's
+-- HashMap-of-groups path.
+SELECT pk, largest_v2 FROM (
+ SELECT (id3 % 100) AS pk, v2 AS largest_v2,
+ DENSE_RANK() OVER (PARTITION BY (id3 % 100) ORDER BY v2 DESC) AS dr_v2
+ FROM large WHERE v2 IS NOT NULL
+) sub_query WHERE dr_v2 <= 2;
+
+-- Window Top-N (DENSE_RANK top-2 per partition, ~1K partitions)
+SELECT pkey, largest_v2 FROM (
+ SELECT (id3 % 1000) AS pkey, v2 AS largest_v2,
+ DENSE_RANK() OVER (PARTITION BY (id3 % 1000) ORDER BY v2 DESC) AS dr_v2
+ FROM large WHERE v2 IS NOT NULL
+) sub_query WHERE dr_v2 <= 2;
+
+-- Window Top-N (DENSE_RANK top-2 per partition, ~1K partitions, heavy ties)
+-- v2 % 10 forces 10 distinct OBY values; most rows share the top-2 distinct
+-- values so appends dominate — exercises the "Case A" append-to-existing-Vec
+-- fast path in PartitionedTopKDenseRank.
+SELECT pkey, largest_v2 FROM (
+ SELECT (id3 % 1000) AS pkey, v2 AS largest_v2,
+ DENSE_RANK() OVER (PARTITION BY (id3 % 1000) ORDER BY (v2 % 10) DESC) AS dr_v2
+ FROM large WHERE v2 IS NOT NULL
+) sub_query WHERE dr_v2 <= 2;
+
+-- Window Top-N (DENSE_RANK top-2 per partition, ~10K partitions, low ties)
+SELECT id2, largest_v2 FROM (
+ SELECT id2, v2 AS largest_v2,
+ DENSE_RANK() OVER (PARTITION BY id2 ORDER BY v2 DESC) AS dr_v2
+ FROM large WHERE v2 IS NOT NULL
+) sub_query WHERE dr_v2 <= 2;
+
+-- Window Top-N (DENSE_RANK top-2 per partition, ~10K partitions, heavy ties)
+SELECT id2, largest_v2 FROM (
+ SELECT id2, v2 AS largest_v2,
+ DENSE_RANK() OVER (PARTITION BY id2 ORDER BY (v2 % 10) DESC) AS dr_v2
+ FROM large WHERE v2 IS NOT NULL
+) sub_query WHERE dr_v2 <= 2;
+
+-- Window Top-N (DENSE_RANK top-2 per partition, ~100K partitions)
+SELECT pk, largest_v2 FROM (
+ SELECT (id3 % 100000) AS pk, v2 AS largest_v2,
+ DENSE_RANK() OVER (PARTITION BY (id3 % 100000) ORDER BY v2 DESC) AS dr_v2
+ FROM large WHERE v2 IS NOT NULL
+) sub_query WHERE dr_v2 <= 2;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org