H2ODB — Percentiles by Passenger Count
H2ODB benchmark · all H2ODB queries
PERCENTILE_CONT(0.5, 0.9) of fare_amount GROUP BY passenger_count
Representative SQL
Rendered for DataFusion with default parameters.
SELECT passenger_count, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY fare_amount) AS median_fare_amount, PERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY fare_amount) AS p90_fare_amountFROM tripsGROUP BY passenger_countORDER BY passenger_countRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def q9_expression_impl(ctx: DataFrameContext) -> Any:
trips = ctx.get_table("trips") col = ctx.col return ( trips.group_by("passenger_count") .agg( col("fare_amount").quantile(0.5, interpolation="linear").alias("median_fare_amount"), col("fare_amount").quantile(0.9, interpolation="linear").alias("p90_fare_amount"), ) .sort("passenger_count") )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 H2ODB
bench = H2ODB(scale_factor=0.01) # your scale factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['Q9'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('h2odb', 'Q9', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/h2odb/queries.py