{"record":{"id":"ee76cd06e13e8971","repo":"databendlabs/databend","slug":"unreachable-ee76cd","errorCode":null,"errorMessage":"_ => unreachable!()","messagePattern":"_ => unreachable!\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_build_state.rs","lineNumber":516,"sourceCode":"                local_raw_entry_spaces.push(local_space);\n                if is_interrupted {\n                    return Err(ErrorCode::aborting());\n                }\n            }};\n        }\n\n        macro_rules! insert_binary_key {\n            ($table: expr, $method: expr, $chunk: expr, $build_keys: expr, $valids: expr, $chunk_index: expr, $entry_size: expr, $local_raw_entry_spaces: expr, ) => {{\n                let keys_state = $method.build_keys_state($build_keys, $chunk.num_rows())?;\n                let build_keys_iter = $method.build_keys_iter(&keys_state)?;\n\n                let space_size = match &keys_state {\n                    // safe to unwrap(): offset.len() >= 1.\n                    KeysState::Column(Column::String(col)) => col.total_bytes_len(),\n                    KeysState::Column(\n                        Column::Binary(col) | Column::Variant(col) | Column::Bitmap(col),\n                    ) => col.data().len(),\n                    _ => unreachable!(),\n                };\n                let valid_num = match &$valids {\n                    Some(valids) => valids.len() - valids.null_count(),\n                    None => $chunk.num_rows(),\n                };\n                let mut entry_local_space: Vec<u8> = Vec::with_capacity(valid_num * entry_size);\n                let mut string_local_space: Vec<u8> = Vec::with_capacity(space_size as usize);\n                let mut raw_entry_ptr = unsafe {\n                    std::mem::transmute::<*mut u8, *mut StringRawEntry>(\n                        entry_local_space.as_mut_ptr(),\n                    )\n                };\n                let mut string_local_space_ptr = string_local_space.as_mut_ptr();\n\n                match $valids {\n                    Some(valids) => {\n                        for (row_index, (key, valid)) in\n                            build_keys_iter.zip(valids.iter()).enumerate()","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_build_state.rs#L498-L534","documentation":"The insert_binary_key! macro in hash_join_build_state.rs assumes that when finalizing a build chunk, the keys state is always a String, Binary, Variant, or Bitmap column. Any other Column variant reaching this match means the caller passed serialized/binary key columns inconsistent with what this macro handles, so the code deliberately panics with unreachable!() instead of returning an error. This is an internal invariant assertion, not a user-facing error.","triggerScenarios":"Calling finalize on a build state whose keys_state holds a non-serialized column type (e.g. Number, Boolean, Nullable variant) while the UniqueSerializer/UniqueSingleBinary insert path expects binary-serialized keys. Usually caused by a code change introducing a new key column type without extending the macro's match arms.","commonSituations":"Developers adding a new data type to hash join keys; running a modified/patched build where key serialization logic was altered; fuzzing or integration tests exercising unusual key types against a binary-key hash table.","solutions":["Inspect the keys_state column variant at the panic and add a matching arm in insert_binary_key! that computes total space size for the new type","Verify build keys are serialized via the serializer path before finalize is invoked","Check recent diffs to hash_join_build_state.rs for newly added key column types missing match coverage","File a bug with the query plan and key types if hit on an unmodified build"],"exampleFix":"// before\n_ => unreachable!(),\n// after\nKeysState::Column(Column::Number(NumberColumn::UInt64(col))) => col.len() * 8,\n_ => unreachable!(\"unexpected keys state for binary key insert\"),","handlingStrategy":"validation","validationCode":"// Before calling finalize, confirm keys_state holds a serializable column type\nfn is_binary_key_state(keys_state: &KeysState) -> bool {\n    matches!(keys_state, KeysState::Column(Column::String(_)\n        | Column::Binary(_) | Column::Variant(_) | Column::Bitmap(_)))\n}\nassert!(is_binary_key_state(&keys_state), \"finalize called with non-binary keys_state\");","typeGuard":"fn is_binary_key_state(keys_state: &KeysState) -> bool {\n    matches!(keys_state, KeysState::Column(Column::String(_)\n        | Column::Binary(_) | Column::Variant(_) | Column::Bitmap(_)))\n}","tryCatchPattern":null,"preventionTips":["Extend insert_binary_key! match arms whenever a new key column type is added","Run hash join tests covering every data type usable as a join key","Include the offending variant in unreachable! messages for faster triage"],"tags":["rust","panic","hash-join","invariant"],"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"}