Skip to content

TPC-DI VQ1

TPC-DI benchmark · all TPC-DI queries

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
'Core Tables Referential Integrity' AS validation_name,
SUM(CASE WHEN orphaned_customers > 0 THEN 1 ELSE 0 END) + SUM(CASE WHEN orphaned_accounts > 0 THEN 1 ELSE 0 END) + SUM(CASE WHEN orphaned_securities > 0 THEN 1 ELSE 0 END) AS integrity_violations,
COUNT(*) AS total_checks
FROM (
SELECT
(
SELECT
COUNT(*)
FROM FactTrade AS f
LEFT JOIN DimCustomer AS c
ON f.SK_CustomerID = c.SK_CustomerID
WHERE
c.SK_CustomerID IS NULL
) AS orphaned_customers,
(
SELECT
COUNT(*)
FROM FactTrade AS f
LEFT JOIN DimAccount AS a
ON f.SK_AccountID = a.SK_AccountID
WHERE
a.SK_AccountID IS NULL
) AS orphaned_accounts,
(
SELECT
COUNT(*)
FROM FactTrade AS f
LEFT JOIN DimSecurity AS s
ON f.SK_SecurityID = s.SK_SecurityID
WHERE
s.SK_SecurityID IS NULL
) AS orphaned_securities
) AS checks

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['VQ1'])

Source

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