{"record":{"id":"98eb116273f9b967","repo":"databendlabs/databend","slug":"column-view-storage-type-mismatch","errorCode":null,"errorMessage":"column view storage type mismatch","messagePattern":"column view storage type mismatch","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/expression/src/block_vec.rs","lineNumber":438,"sourceCode":"\n        DataBlock::new(entries, 0)\n    }\n\n    fn init_typed<T: AccessType>(entry: BlockEntry, size_hit: usize) -> Result<ColumnStorage> {\n        let data_type = entry.data_type();\n        let mut data = Box::new(Vec::<ColumnView<T>>::with_capacity(size_hit));\n        data.push(entry.downcast::<T>()?);\n        Ok(ColumnStorage {\n            data_type,\n            data: data as _,\n        })\n    }\n\n    fn push_typed<T: AccessType>(storage: &mut ColumnStorage, entry: BlockEntry) -> Result<()> {\n        let views = storage\n            .data\n            .downcast_mut::<Vec<ColumnView<T>>>()\n            .expect(\"column view storage type mismatch\");\n        views.push(entry.downcast::<T>()?);\n        Ok(())\n    }\n\n    fn replace_typed<T: AccessType>(storage: &mut ColumnStorage, index: usize, entry: BlockEntry) {\n        let views = storage\n            .data\n            .downcast_mut::<Vec<ColumnView<T>>>()\n            .expect(\"column view storage type mismatch\");\n        let view = entry.downcast::<T>().expect(\"column view type mismatch\");\n        views[index] = view;\n    }\n\n    fn handler_for(data_type: &DataType) -> TypeHandler {\n        match data_type {\n            DataType::Nullable(inner) => Self::handler_for_nullable(inner),\n            _ => Self::handler_for_non_nullable(data_type),\n        }","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/expression/src/block_vec.rs#L420-L456","documentation":"push_typed downcasts the column storage's underlying Any data to Vec<ColumnView<T>> for the compile-time type T of the pushed entry. The expect panics when the storage holds views of a different type than the handler's T — the storage type and the entry type disagree, an internal type-tag invariant violation.","triggerScenarios":"Calling push_typed (via BlockVec push paths) with an entry whose AccessType T does not match the type the ColumnStorage was created with — e.g. handler lookup used one DataType while the storage was initialized with another.","commonSituations":"Bugs in type-handler dispatch (handler_for returning the wrong specialization), schema/type changes not propagated to existing column storage, or expressions producing values of a different type than the declared column type.","solutions":["Verify the entry's data type matches the storage's declared data_type before pushing.","Ensure handler_for and storage construction use the same (fully unwrapped, non-nullable-normalized) DataType.","Check for schema mismatch upstream: a query or insert supplying values of the wrong type should be rejected earlier.","File a bug with the query/types involved; this is an internal invariant violation."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if entry.data_type() != &storage.data_type {\n    return Err(ErrorCode::Internal(\"pushed entry type does not match column storage type\"));\n}","typeGuard":"fn matches_storage<T: AccessType>(storage: &ColumnStorage, entry: &BlockEntry) -> bool {\n    entry.data_type() == &storage.data_type && storage.data.downcast_ref::<Vec<ColumnView<T>>>().is_some()\n}","tryCatchPattern":null,"preventionTips":["Build TypeHandlers and storage from the same normalized DataType","Type-check inputs at the query boundary before they reach column storage","Cover push paths with type-mismatch unit tests"],"tags":["rust","panic","downcast","type-mismatch"],"backgroundTag":"type-mismatch","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"}