TPC-DI AQ1
TPC-DI benchmark · all TPC-DI queries
Representative SQL
Rendered for DataFusion with default parameters.
SELECT 'Customer Profitability Analysis' AS analysis_name, c.Tier, c.Country, c.Gender, COUNT(DISTINCT c.SK_CustomerID) AS customer_count, COUNT(t.TradeID) AS total_trades, SUM(t.Quantity * t.TradePrice) AS total_trade_value, SUM(t.Fee + t.Commission + t.Tax) AS total_fees_generated, AVG(t.TradePrice) AS avg_trade_price, AVG(c.NetWorth) AS avg_net_worth, AVG(c.CreditRating) AS avg_credit_rating, SUM(t.Quantity * t.TradePrice) / COUNT(DISTINCT c.SK_CustomerID) AS revenue_per_customer, SUM(t.Fee + t.Commission + t.Tax) / COUNT(DISTINCT c.SK_CustomerID) AS fees_per_customer, COUNT(t.TradeID) / COUNT(DISTINCT c.SK_CustomerID) AS trades_per_customerFROM DimCustomer AS cLEFT JOIN FactTrade AS t ON c.SK_CustomerID = t.SK_CustomerIDLEFT JOIN DimDate AS d ON t.SK_CreateDateID = d.SK_DateIDWHERE c.IsCurrent IS TRUE AND ( d.CalendarYearID >= 2015 AND d.CalendarYearID <= 2019 ) AND t.Status = 'Completed'GROUP BY c.Tier, c.Country, c.GenderHAVING COUNT(t.TradeID) > 10ORDER BY total_fees_generated DESC, total_trade_value DESCLIMIT 50Representative 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 factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['AQ1'])Source
Query text: benchbox/core/tpcdi/query_analytics.py