{"record":{"id":"4463127a9b382c8e","repo":"databendlabs/databend","slug":"internal-error-entered-unreachable-code-446312","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/storages/common/index/src/bloom_index.rs","lineNumber":988,"sourceCode":"                .get_by_offset(index_column.index)\n                .value()\n                .convert_to_full_column(field_type, 1);\n\n            let (column, data_type) = match field_type.remove_nullable() {\n                DataType::Map(box inner_ty) => {\n                    // Add bloom filter for the value of map type\n                    let map_column = if field_type.is_nullable() {\n                        let nullable_column =\n                            NullableType::<MapType<AnyType, AnyType>>::try_downcast_column(&column)\n                                .unwrap();\n                        nullable_column.column\n                    } else {\n                        MapType::<AnyType, AnyType>::try_downcast_column(&column).unwrap()\n                    };\n                    let column = map_column.underlying_column().values;\n\n                    let DataType::Tuple(kv_tys) = inner_ty else {\n                        unreachable!();\n                    };\n                    let val_type = kv_tys[1].clone();\n                    // Extract JSON value of string type to create bloom index,\n                    // other types of JSON value will be ignored.\n                    if val_type.remove_nullable() == DataType::Variant {\n                        let mut builder = ColumnBuilder::with_capacity(\n                            &DataType::Nullable(Box::new(DataType::String)),\n                            column.len(),\n                        );\n                        for val in column.iter() {\n                            if let ScalarRef::Variant(v) = val {\n                                let raw_jsonb = RawJsonb::new(v);\n                                if let Ok(Some(str_val)) = raw_jsonb.as_str() {\n                                    builder.push(ScalarRef::String(&str_val));\n                                    continue;\n                                }\n                            }\n                            builder.push_default();","sourceCodeStart":970,"sourceCodeEnd":1006,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/storages/common/index/src/bloom_index.rs#L970-L1006","documentation":"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).","triggerScenarios":"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).","commonSituations":"Tables created/altered with MAP under one Databend version and indexed under another; custom ingest paths writing mismatched schema metadata.","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!()"],"exampleFix":"// before\nlet DataType::Tuple(kv_tys) = inner_ty else {\n    unreachable!();\n};\n// after\nlet DataType::Tuple(kv_tys) = inner_ty else {\n    return Err(ErrorCode::Internal(format!(\n        \"expect map inner tuple, got {:?}\", inner_ty)));\n};","handlingStrategy":"validation","validationCode":"-- verify map column layout before creating bloom index\nDESC <table>;\n-- expect Map(Tuple(String, T)); if inner is not Tuple, fix schema first","typeGuard":null,"tryCatchPattern":"try {\n  createTableWithBloomIndex();\n} catch (e) {\n  if (e.code === 1001) {\n    // drop the index, verify schema with DESC, rebuild index\n  }\n}","preventionTips":["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"],"tags":["rust","bloom-index","internal-error","map","schema"],"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"}