apache / apache/datafusion

Join Graph

Open
#18,250 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

This task is part of feature #18249, aimed at illustrating what a query’s join graph looks like. We use TPC-H Q5 as the example.

TPC-H Query 5 involves 6 tables and 6 joins, as our example.

```SQL
select
n_name,
sum(l_extendedprice * (1 - l_discount)) as revenue
from
customer,
orders,
lineitem,
supplier,
nation,
region
where
c_custkey = o_custkey
and l_orderkey = o_orderkey
and l_suppkey = s_suppkey
and c_nationkey = s_nationkey
and s_nationkey = n_nationkey
and n_regionkey = r_regionkey
and r_name = 'ASIA'
and o_orderdate >= date '1994-01-01'
and o_orderdate < date '1995-01-01'
group by
n_name
order by
revenue desc;
```

## Join Graph

Since our focus is join order enumeration, we’ll represent the query as a join graph:
- Tables are shown as circles
- Joins appear as edges between circles:
- Directed edges indicate many-to-one joins
- Undirected edges indicate many-to-many joins
- Columns inside a circle denote selection predicates (filters) on that table
- Orders table is filtered on o_orderdate with ~15% selectivity.
- Region table is filtered o r_name and 20% selectivity
- Group-by column: n_name.
- Order-by field: the aggregation
- Color coding reflects table partitioning, sort order, and size category

These properties illustrate factors that influence join enumeration in the next section. They’re optional and can be extended or omitted based on specific needs

Image

Figure 1: Join Graph of tpc-h Q5

Contributor guide

Open the contributing guide

Research direction

Start by reading feature #18249 and the TPC-H Q5 example in this issue, then trace the existing join-order enumeration entry points. Done means the join graph represents the six tables, six joins, selection predicates, grouping, ordering, and the stated optional properties; no files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.