Read Primitives — Window Unbounded Frame
Read Primitives benchmark · all Read Primitives queries
Window aggregations with the same unbounded frame definition
Representative SQL
Rendered for DataFusion with default parameters.
SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity, FIRST_VALUE(l_quantity) OVER ( PARTITION BY l_orderkey ORDER BY l_linenumber ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS first_line_qty, LAST_VALUE(l_quantity) OVER ( PARTITION BY l_orderkey ORDER BY l_linenumber ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS last_line_qtyFROM lineitemWHERE l_orderkey BETWEEN 1 AND 5000Representative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def window_unbounded_frame_expression_impl(ctx: DataFrameContext) -> Any: lineitem = ctx.get_table("lineitem") col = ctx.col lit = ctx.lit
return ( lineitem.filter((col("l_orderkey") >= lit(1)) & (col("l_orderkey") <= lit(5000))) .sort(["l_orderkey", "l_linenumber"]) .with_columns( [ col("l_quantity").first().over("l_orderkey").alias("first_line_qty"), col("l_quantity").last().over("l_orderkey").alias("last_line_qty"), ] ) .select("l_orderkey", "l_linenumber", "l_shipdate", "l_quantity", "first_line_qty", "last_line_qty") )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_unbounded_frame'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'window_unbounded_frame', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py