Skip to content

TPC-DI VQ9

TPC-DI benchmark · all TPC-DI queries

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
'Trade Price Reasonableness Validation' AS validation_name,
COUNT(*) AS total_trades,
SUM(CASE WHEN TradePrice <= 0 THEN 1 ELSE 0 END) AS negative_or_zero_prices,
SUM(CASE WHEN TradePrice > 10000.0 THEN 1 ELSE 0 END) AS extremely_high_prices,
SUM(CASE WHEN Fee < 0 OR Commission < 0 OR Tax < 0 THEN 1 ELSE 0 END) AS negative_fees,
MIN(TradePrice) AS min_trade_price,
MAX(TradePrice) AS max_trade_price,
AVG(TradePrice) AS avg_trade_price,
CASE
WHEN (
SUM(CASE WHEN TradePrice <= 0 THEN 1 ELSE 0 END) + SUM(CASE WHEN TradePrice > 10000.0 THEN 1 ELSE 0 END) + SUM(CASE WHEN Fee < 0 OR Commission < 0 OR Tax < 0 THEN 1 ELSE 0 END)
) = 0
THEN 'PASS'
ELSE 'FAIL'
END AS status
FROM FactTrade

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

Source

Query text: benchbox/core/tpcdi/query_validation.py