Skip to content

TPC-Havoc Q5_v5

TPC-Havoc benchmark · all TPC-Havoc queries

Representative SQL

Rendered for DataFusion with default parameters.

WITH asia_nations AS (
SELECT
n_nationkey,
n_name
FROM nation, region
WHERE
n_regionkey = r_regionkey AND r_name = 'ASIA'
), qualified_orders AS (
SELECT
o_orderkey,
o_custkey
FROM orders
WHERE
o_orderdate >= CAST('1994-01-01' AS DATE)
AND o_orderdate < CAST('1994-01-01' AS DATE) + INTERVAL '1 YEAR'
), qualified_customers AS (
SELECT
c_custkey,
c_nationkey
FROM customer
), qualified_suppliers AS (
SELECT
s_suppkey,
s_nationkey
FROM supplier
), revenue_base AS (
SELECT
an.n_name,
l.l_extendedprice * (
1 - l.l_discount
) AS item_revenue
FROM asia_nations AS an
JOIN qualified_suppliers AS qs
ON an.n_nationkey = qs.s_nationkey
JOIN qualified_customers AS qc
ON qs.s_nationkey = qc.c_nationkey
JOIN qualified_orders AS qo
ON qc.c_custkey = qo.o_custkey
JOIN lineitem AS l
ON qo.o_orderkey = l.l_orderkey AND qs.s_suppkey = l.l_suppkey
)
SELECT
n_name,
SUM(item_revenue) AS revenue
FROM revenue_base
GROUP BY
n_name
ORDER BY
revenue DESC

Representative DataFrame

No DataFrame implementation is registered for this query.

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

Source

Query text: benchbox/core/tpchavoc/variant_sets/q05.py