Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 12 additions & 138 deletions docs/getting-started/example-datasets/tpch.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,18 @@ INSERT INTO lineitem SELECT * FROM s3('https://clickhouse-datasets.s3.amazonaws.
Setting [`join_use_nulls`](../../operations/settings/settings.md#join_use_nulls) should be enabled to produce correct results according to SQL standard.
:::

The queries are generated by `./qgen -s <scaling_factor>`. Example queries for `s = 100`:
:::note
Some TPC-H queries query use correlated subqueries which are available since v25.8.
Please use at least this ClickHouse version to run the queries.

In ClickHouse versions 25.5, 25.6, 25.7, it is necessary to set additionally:

```sql
SET allow_experimental_correlated_subqueries = 1;
```
:::

The queries are generated by `./qgen -s <scaling_factor>`. Example queries for `s = 100` below:

**Correctness**

Expand Down Expand Up @@ -278,63 +289,6 @@ ORDER BY
p_partkey;
```

::::note
Until v25.5, the query did not work out-of-the box because scalar correlated subqueries were unsupported.
Until v25.8, the query requires enabling the `allow_experimental_correlated_subqueries` setting.

This alternative formulation works and was verified to return the reference results.

```sql
WITH MinSupplyCost AS (
SELECT
ps_partkey,
MIN(ps_supplycost) AS min_supplycost
FROM
partsupp ps
JOIN
supplier s ON ps.ps_suppkey = s.s_suppkey
JOIN
nation n ON s.s_nationkey = n.n_nationkey
JOIN
region r ON n.n_regionkey = r.r_regionkey
WHERE
r.r_name = 'EUROPE'
GROUP BY
ps_partkey
)
SELECT
s.s_acctbal,
s.s_name,
n.n_name,
p.p_partkey,
p.p_mfgr,
s.s_address,
s.s_phone,
s.s_comment
FROM
part p
JOIN
partsupp ps ON p.p_partkey = ps.ps_partkey
JOIN
supplier s ON s.s_suppkey = ps.ps_suppkey
JOIN
nation n ON s.s_nationkey = n.n_nationkey
JOIN
region r ON n.n_regionkey = r.r_regionkey
JOIN
MinSupplyCost msc ON ps.ps_partkey = msc.ps_partkey AND ps.ps_supplycost = msc.min_supplycost
WHERE
p.p_size = 15
AND p.p_type LIKE '%BRASS'
AND r.r_name = 'EUROPE'
ORDER BY
s.s_acctbal DESC,
n.n_name,
s.s_name,
p.p_partkey;
```
::::

**Q3**

```sql
Expand Down Expand Up @@ -388,40 +342,6 @@ ORDER BY
o_orderpriority;
```

::::note
Until v25.4, the query did not work out-of-the box because correlated subqueries were unsupported.
Until v25.8, the query requires enabling allow_experimental_correlated_subqueries setting.

This alternative formulation works and was verified to return the reference results.

```sql
WITH ValidLineItems AS (
SELECT
l_orderkey
FROM
lineitem
WHERE
l_commitdate < l_receiptdate
GROUP BY
l_orderkey
)
SELECT
o.o_orderpriority,
COUNT(*) AS order_count
FROM
orders o
JOIN
ValidLineItems vli ON o.o_orderkey = vli.l_orderkey
WHERE
o.o_orderdate >= DATE '1993-07-01'
AND o.o_orderdate < DATE '1993-07-01' + INTERVAL '3' MONTH
GROUP BY
o.o_orderpriority
ORDER BY
o.o_orderpriority;
```
::::

**Q5**

```sql
Expand Down Expand Up @@ -843,38 +763,6 @@ WHERE
);
```

::::note
Until v25.5, the query did not work out-of-the box because scalar correlated subqueries were unsupported.
Until v25.8, the query requires enabling allow_experimental_correlated_subqueries setting.

This alternative formulation works and was verified to return the reference results.

```sql
WITH AvgQuantity AS (
SELECT
l_partkey,
AVG(l_quantity) * 0.2 AS avg_quantity
FROM
lineitem
GROUP BY
l_partkey
)
SELECT
SUM(l.l_extendedprice) / 7.0 AS avg_yearly
FROM
lineitem l
JOIN
part p ON p.p_partkey = l.l_partkey
JOIN
AvgQuantity aq ON l.l_partkey = aq.l_partkey
WHERE
p.p_brand = 'Brand#23'
AND p.p_container = 'MED BOX'
AND l.l_quantity < aq.avg_quantity;

```
::::

**Q18**

```sql
Expand Down Expand Up @@ -995,11 +883,6 @@ ORDER BY
s_name;
```

::::note
Until v25.5, the query did not work out-of-the box because scalar correlated subqueries were unsupported.
Until v25.8, the query requires enabling allow_experimental_correlated_subqueries setting.
::::

**Q21**

```sql
Expand Down Expand Up @@ -1043,10 +926,6 @@ ORDER BY
numwait DESC,
s_name;
```
::::note
Until v25.4, the query did not work out-of-the box because correlated subqueries were unsupported.
Until v25.8, the query requires enabling allow_experimental_correlated_subqueries setting.
::::

**Q22**

Expand Down Expand Up @@ -1088,8 +967,3 @@ GROUP BY
ORDER BY
cntrycode;
```

::::note
Until v25.4, the query did not work out-of-the box because correlated subqueries were unsupported.
Until v25.8, the query requires enabling allow_experimental_correlated_subqueries setting.
::::