Skip to content

ClickBench — URL Hash IN Clause

ClickBench benchmark · all ClickBench queries

URLHash + EventDate with IN clause filter and OFFSET 100

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
URLHash,
EventDate,
COUNT(*) AS PageViews
FROM hits
WHERE
CounterID = 62
AND EventDate >= '2013-07-01'
AND EventDate <= '2013-07-31'
AND IsRefresh = 0
AND TraficSourceID IN (-1, 6)
AND RefererHash = 3594120000172545465
GROUP BY
URLHash,
EventDate
ORDER BY
PageViews DESC
LIMIT 10
OFFSET 100

Representative DataFrame

Expression family (Polars, PySpark, DataFusion), default parameters.

def impl(ctx: DataFrameContext) -> Any:
result = _expr_filter(ctx, _hits(ctx), filter_code)
result = _expr_derive(ctx, result, derive_code)
result = result.group_by(*groups).agg(*[_expr_agg(ctx, token) for token in agg_spec.split(";")])
if sort_spec:
sort_cols, descending = _sort_parts(sort_spec)
result = result.sort(sort_cols, descending=descending)
if offset:
return result.slice(offset, limit)
return result.limit(limit) if limit else result

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 ClickBench
bench = ClickBench(scale_factor=1.0) # your scale factor
queries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQL
print(queries['Q41'])

For the DataFrame form:

from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('clickbench', 'Q41', family="expression").source) # or family="pandas"

Source

Query text: benchbox/core/clickbench/queries.py