databendlabs/databend · error
_ => unreachable!()
Error message
_ => unreachable!()
What it means
HashJoinFactory::create_grace_join panics when the join type is not one of the nine explicitly handled JoinType variants (Inner, Left, LeftSemi, LeftAnti, Right, RightSemi, RightAnti, and cross/nested-loop variants). It is an internal exhaustiveness guard: grace join construction assumes the planner only produces supported join types.
Solutions
- Inspect the JoinType value passed in and ensure create_grace_join is only called for grace-supported types
- Add the missing JoinType arm to the match at hash_join_factory.rs:302 if the type should be supported
- Route unsupported types (e.g. cross/nested-loop) to create_memory_join or the nested-loop executor instead
- Add a compile-time exhaustiveness test or match on the enum without a wildcard arm
Example fix
// before
match typ {
JoinType::Inner => { ... }
...
JoinType::RightAnti => { ... }
_ => unreachable!(),
}
// after
JoinType::Cross => return Err(ErrorCode::Unimplemented(
"grace join does not support cross join")),
_ => unreachable!(), Defensive patterns
Strategy: validation
Validate before calling
debug_assert!(matches!(typ, JoinType::Inner | JoinType::Left | JoinType::LeftSemi | JoinType::LeftAnti | JoinType::Right | JoinType::RightSemi | JoinType::RightAnti), "grace join unsupported type: {:?}", typ); Type guard
fn supports_grace_join(t: &JoinType) -> bool {
!matches!(t, JoinType::Cross)
} Prevention
- Match JoinType without a wildcard so the compiler forces updates on new variants
- Check JoinType dispatch coverage when adding join types to the planner
- Prefer returning ErrorCode over unreachable!() at public factory boundaries
- Add factory-level tests for every JoinType
When it happens
Trigger: Calling HashJoinFactory::create_grace_join with a JoinType not covered by the match (e.g. a newly added JoinType variant, or a NestedLoop/Cross join passed into the grace-join path).
Common situations: Adding a new join type to the planner without extending the factory, constructing joins directly in tests with an exotic JoinType, or rebasing code where JoinType gained a variant.
Related errors
- _ => unreachable!()
- _ => unreachable!()
- HashJoinHashTable::NestedLoop(_) => unreachable!()
- HashJoinHashTable::NestedLoop(_) => unreachable!()
- _ => unreachable!()
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/cb0bb6c566134cb8.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/service/src/pipelines/processors/transforms/new_hash_join/hash_join_factory.rs:302
let anti_right_hash_join = AntiRightHashJoin::create(
&self.ctx,
self.function_ctx.clone(),
self.hash_method.clone(),
self.desc.clone(),
self.create_basic_state(id)?,
)?;
Ok(Box::new(GraceHashJoin::create(
self.ctx.clone(),
self.function_ctx.clone(),
self.hash_method.clone(),
self.desc.clone(),
self.create_grace_state(id + 1)?,
anti_right_hash_join,
0,
)?))
}
_ => unreachable!(),
}
}
/// Create a basic memory join (used internally by HybridHashJoin)
pub fn create_memory_join(
self: &Arc<Self>,
typ: JoinType,
level: usize,
) -> Result<Box<dyn GraceMemoryJoin>> {
let basic_state = self.create_basic_state(level)?;
match typ {
JoinType::Inner => {
let settings = self.ctx.get_settings();
let nested_loop_desc = self
.desc
.create_nested_loop_desc(&settings, &self.function_ctx)?;
let inner = InnerHashJoin::create(View on GitHub (pinned to 288d84d76e)