{"record":{"id":"02c2e09d811f8f57","repo":"databendlabs/databend","slug":"hashjoinhashtable-nestedloop-unreachable-02c2e0","errorCode":null,"errorMessage":"HashJoinHashTable::NestedLoop(_) => unreachable!()","messagePattern":"HashJoinHashTable::NestedLoop\\(_\\) => unreachable!\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/pipelines/processors/transforms/new_hash_join/memory/inner_join.rs","lineNumber":153,"sourceCode":"        let probe_block = data.project(&self.desc.probe_projection);\n\n        let joined_stream = with_join_hash_method!(|T| match self.basic_state.hash_table.deref() {\n            HashJoinHashTable::T(table) => {\n                let probe_hash_statistics = &mut self.performance_context.probe_hash_statistics;\n                probe_hash_statistics.clear(probe_block.num_rows());\n\n                let probe_data = ProbeData::new(keys, valids, probe_hash_statistics);\n                let probe_keys_stream = table.probe_matched(probe_data)?;\n\n                InnerHashJoinStream::create(\n                    probe_block,\n                    self.basic_state.clone(),\n                    probe_keys_stream,\n                    self.desc.clone(),\n                    &mut self.performance_context.probe_result,\n                )\n            }\n            HashJoinHashTable::NestedLoop(_) => unreachable!(),\n            HashJoinHashTable::Null => {\n                return Err(ErrorCode::AbortedQuery(\n                    \"Aborted query, because the hash table is uninitialized.\",\n                ));\n            }\n        });\n\n        match &mut self.performance_context.filter_executor {\n            None => Ok(joined_stream),\n            Some(filter_executor) => Ok(InnerHashJoinFilterStream::create(\n                joined_stream,\n                filter_executor,\n            )),\n        }\n    }\n}\n\nstruct InnerHashJoinStream<'a> {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/pipelines/processors/transforms/new_hash_join/memory/inner_join.rs#L135-L171","documentation":"InnerHashJoin::probe_block panics when the probe side encounters a NestedLoop hash table variant, which by design never participates in hash probing. The match otherwise returns AbortedQuery for an uninitialized (Null) table, so this arm is a pure internal invariant check.","triggerScenarios":"A nested-loop join (cross or non-equi) is executed through the memory hash-join probe path, i.e. probe_block runs while state.hash_table holds HashJoinHashTable::NestedLoop.","commonSituations":"Incorrect executor selection for cross joins, refactor where inner-join probe processors are attached to a nested-loop pipeline, or tests wiring a NestedLoop table into InnerHashJoin.","solutions":["Check join-type/equi-condition detection upstream so nested-loop joins never build InnerHashJoin probe processors","Ensure the processor used matches the HashJoinHashTable variant chosen at build time","Convert the arm to ErrorCode::Internal with context to make future hits diagnosable instead of a bare panic","Run new_hash_join inner-join integration tests after executor-routing changes"],"exampleFix":"// before\nHashJoinHashTable::NestedLoop(_) => unreachable!(),\n// after\nHashJoinHashTable::NestedLoop(_) => Err(ErrorCode::Internal(\n    \"NestedLoop table cannot be probed by inner hash join\")),","handlingStrategy":"validation","validationCode":"debug_assert!(!matches!(*self.basic_state.state.hash_table.deref(), HashJoinHashTable::NestedLoop(_)), \"NestedLoop table in inner join probe path\");","typeGuard":"fn probeable(t: &HashJoinHashTable) -> bool {\n    !matches!(t, HashJoinHashTable::NestedLoop(_))\n}","tryCatchPattern":null,"preventionTips":["Ensure cross/non-equi joins never attach inner hash join probe processors","Check executor selection when changing join dispatch in the planner","Convert unreachable arms to ErrorCode::Internal for diagnosability","Run new_hash_join integration tests after routing changes"],"tags":["rust","panic","hash-join","probe"],"backgroundTag":"internal-invariant-violation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}