Read Primitives — Window Dense Rank
Read Primitives benchmark · all Read Primitives queries
Window function DENSE_RANK() OVER (PARTITION BY … ORDER BY …)
Representative SQL
Rendered for DataFusion with default parameters.
SELECT l_orderkey, l_partkey, l_quantity, l_extendedprice, DENSE_RANK() OVER (PARTITION BY l_orderkey ORDER BY l_extendedprice DESC) AS price_rank, PERCENT_RANK() OVER (PARTITION BY l_orderkey ORDER BY l_quantity) AS quantity_percentile, CUME_DIST() OVER (PARTITION BY l_orderkey ORDER BY l_extendedprice) AS price_distributionFROM lineitemWHERE l_orderkey <= 10000ORDER BY l_orderkey, price_rankRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def window_dense_rank_expression_impl(ctx: DataFrameContext) -> Any: import polars as pl
n = pl.len().over("l_orderkey") return ( ctx.get_table("lineitem") .native.filter(pl.col("l_orderkey") <= 10000) .with_columns( pl.col("l_extendedprice").rank("dense", descending=True).over("l_orderkey").alias("price_rank"), ((pl.col("l_quantity").rank("min").over("l_orderkey") - 1) / (n - 1)) .fill_nan(0.0) .fill_null(0.0) .alias("quantity_percentile"), (pl.col("l_extendedprice").rank("max").over("l_orderkey") / n).alias("price_distribution"), ) .sort(["l_orderkey", "price_rank"]) .select( "l_orderkey", "l_partkey", "l_quantity", "l_extendedprice", "price_rank", "quantity_percentile", "price_distribution", ) )Get the exact query for your run
The blocks above are representative. To get the precise statement a specific platform runs at a specific scale, substitute your own values:
from benchbox import ReadPrimitives
bench = ReadPrimitives(scale_factor=0.01) # your scale factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['window_multiple_orderings'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'window_multiple_orderings', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py