bug(optimizer): join reordering panics for nested ANY JOIN
Maintainers usually reply within 1 day
@forsaken628 is already working on this.
Since Oct 23, 2026.
Assessment
This issue has not been assessed yet.
Description
Problem
Confirmed on main: a query containing ANY JOIN panics during join reordering instead of returning the existing “ANY JOIN is not supported yet” error. This is not specific to an intermediate PR revision.
Reproduce
Run in a fresh schema with default settings:
CREATE TABLE rf_any_a(k INT, v INT);
CREATE TABLE rf_any_b(k INT, v INT);
CREATE TABLE rf_any_c(k INT);
INSERT INTO rf_any_a VALUES (1,10), (1,11), (2,20);
INSERT INTO rf_any_b VALUES (1,100), (2,200);
INSERT INTO rf_any_c VALUES (0), (1);
SELECT q.k, q.v
FROM (
SELECT a.k, a.v
FROM rf_any_a a LEFT ANY JOIN rf_any_b b ON a.k = b.k
) q
JOIN rf_any_c c ON q.k = c.k
ORDER BY q.k, q.v;
Actual: error 1104, no entry found for key. EXPLAIN fails too. The panic is at self.table_index_map[table] in dphyp.rs:745.
For comparison, setting disable_join_reorder = 1 makes SELECT return error 1002, ANY JOIN is not supported yet. This SET is only a diagnostic control, not required to reproduce. The corresponding RIGHT ANY JOIN form (replace rf_any_a a LEFT ANY JOIN rf_any_b b with rf_any_b b RIGHT ANY JOIN rf_any_a a) also fails. With reordering disabled, EXPLAIN succeeds and shows the ANY join; the unsupported-operation check is reached only when SELECT builds its execution pipeline.
Expected: reject unsupported ANY JOIN with a clear error, without an optimizer panic.
Confirmed on main
Rebuilt and ran the SQL above on main commit 2558f77fd87b0829651ec49c0e1151b9fabc6383 on 2026-10-27. This was the latest main head checked for this run. The clean detached worktree had no tracked modifications; no PR patches were applied.
Environment: macOS ARM64, debug OSS databend-query-oss and databend-meta-oss built from that commit, a fresh isolated single-node deployment with filesystem storage, and bendsql over HTTP.
SELECT version() returned:
Databend Query v1.2.954-2558f77fd8(rust-1.100.0-nightly-2026-10-27T05:03:13.700400000Z)
Verified defaults: disable_join_reorder = 0, enable_dphyp = 1. No SET is needed to trigger the panic.
| Nested join | Operation | Default settings | disable_join_reorder = 1 (control) |
|---|---|---|---|
| LEFT ANY | SELECT | error 1104: no entry found for key |
error 1002: ANY JOIN is not supported yet |
| LEFT ANY | EXPLAIN | error 1104: no entry found for key |
plan generated successfully |
| RIGHT ANY | SELECT | error 1104: no entry found for key |
error 1002: ANY JOIN is not supported yet |
| RIGHT ANY | EXPLAIN | error 1104: no entry found for key |
plan generated successfully |
All four default-setting failures logged a panic in DPhpyOptimizer::build_join_order_edges at src/query/sql/src/planner/optimizer/optimizers/hyper_dp/dphyp.rs:745:62, indexing self.table_index_map[table].
As a fixture control, replacing LEFT ANY with an ordinary INNER JOIN returned (1,10) and (1,11). The server also answered SELECT version(), 1 after all panic cases; these were caught query-level panics, not a server-process crash.
- Dominant language
- Rust
- Stars
- 9.5k
- Forks
- 903
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 204
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from databendlabs/databend
-
bug: segment pruning skips rows when only some blocks have statistics of an added columnPossibly taken @zhyass claimed this today. OpenC-bug
databendlabs/databend#21244 · 1 assignee ·
Maintainers usually reply within 1 day
-
bug: ORDER BY ... NULLS LAST LIMIT returns wrong rows when an inverted index answers the filter and the sort column has NULLsPossibly taken @b41sh claimed this today. OpenC-bug
databendlabs/databend#21243 · 1 assignee ·
Maintainers usually reply within 1 day
-
Feature: Reduce role-graph work for explicit secondary rolesPossibly taken @TCeason claimed this 1 day ago. OpenC-feature
databendlabs/databend#21226 · 1 assignee ·
Maintainers usually reply within 1 day
-
Feature: Key role-dependent query results by authorization contextPossibly taken @TCeason claimed this 1 day ago. OpenC-feature
databendlabs/databend#21225 · 1 assignee ·
Maintainers usually reply within 1 day
-
bug: filters folded to false on block statistics drop matching rows: cast-eliminated equality under NOT, float arithmetic over NaN and infinities, variant IS DISTINCT FROMPossibly taken @forsaken628 claimed this 1 day ago. OpenC-bug
databendlabs/databend#21216 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in databendlabs/databend
Similar issues
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
eliasstravik/herdr-projects#1605 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
jlcodes99/cockpit-tools#3332 ·
Maintainers usually reply within 3 days
-
Cognito: the email MFA code (EMAIL_OTP challenge after a password flow) has 8 digits; AWS delivers 6Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/aws-emulator#692 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 82/100
pamburus/hl#1779 · 1 comment ·
Maintainers usually reply within 1 day