databendlabs/databend · error
internal error: entered unreachable code
Error message
internal error: entered unreachable code
What it means
When building a bloom index for a Map column, the code downcasts the inner column and expects the inner type to be a Tuple (the key/value pair struct of the map). If the declared inner type is anything else, the `let ... else` guard hits `unreachable!()`, producing internal error 1001 during index generation (CREATE TABLE ... with bloom index or index build).
Solutions
- Drop and rebuild the bloom index so it is regenerated against the current schema
- Verify the map column schema (`DESC table`) shows Map(Tuple(k,v)) and re-create the table/migrate data if not
- Report as a bug with schema and version: the guard should return an internal error with the type name instead of unreachable!()
Example fix
// before
let DataType::Tuple(kv_tys) = inner_ty else {
unreachable!();
};
// after
let DataType::Tuple(kv_tys) = inner_ty else {
return Err(ErrorCode::Internal(format!(
"expect map inner tuple, got {:?}", inner_ty)));
}; Defensive patterns
Strategy: validation
Validate before calling
-- verify map column layout before creating bloom index DESC <table>; -- expect Map(Tuple(String, T)); if inner is not Tuple, fix schema first
Try / catch
try {
createTableWithBloomIndex();
} catch (e) {
if (e.code === 1001) {
// drop the index, verify schema with DESC, rebuild index
}
} Prevention
- Declare MAP columns as Map(String, T) (engine stores Tuple(k,v)); never hand-craft exotic map types
- Rebuild indexes after schema migrations/upgrades
- Check SHOW CREATE TABLE matches expected types before adding indexes
When it happens
Trigger: Building a bloom index on a MAP column whose inner type metadata is not Tuple(k,v) — i.e. schema/type metadata inconsistent with the stored column layout (e.g. Variant-typed map values mis-declared, or schema drift after engine changes).
Common situations: Tables created/altered with MAP under one Databend version and indexed under another; custom ingest paths writing mismatched schema metadata.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- internal error: entered unreachable code
- invalid map type
- internal error: entered unreachable code
- internal error: entered unreachable code
- internal error: entered unreachable code
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/4463127a9b382c8e.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/storages/common/index/src/bloom_index.rs:988
.get_by_offset(index_column.index)
.value()
.convert_to_full_column(field_type, 1);
let (column, data_type) = match field_type.remove_nullable() {
DataType::Map(box inner_ty) => {
// Add bloom filter for the value of map type
let map_column = if field_type.is_nullable() {
let nullable_column =
NullableType::<MapType<AnyType, AnyType>>::try_downcast_column(&column)
.unwrap();
nullable_column.column
} else {
MapType::<AnyType, AnyType>::try_downcast_column(&column).unwrap()
};
let column = map_column.underlying_column().values;
let DataType::Tuple(kv_tys) = inner_ty else {
unreachable!();
};
let val_type = kv_tys[1].clone();
// Extract JSON value of string type to create bloom index,
// other types of JSON value will be ignored.
if val_type.remove_nullable() == DataType::Variant {
let mut builder = ColumnBuilder::with_capacity(
&DataType::Nullable(Box::new(DataType::String)),
column.len(),
);
for val in column.iter() {
if let ScalarRef::Variant(v) = val {
let raw_jsonb = RawJsonb::new(v);
if let Ok(Some(str_val)) = raw_jsonb.as_str() {
builder.push(ScalarRef::String(&str_val));
continue;
}
}
builder.push_default();View on GitHub (pinned to 288d84d76e)