{"record":{"id":"fa6a4874b3c20fbb","repo":"quickwit-oss/tantivy","slug":"no-multivalued-index-is-allowed-when-stacking-colu","errorCode":null,"errorMessage":"No multivalued index is allowed when stacking column index","messagePattern":"No multivalued index is allowed when stacking column index","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"columnar/src/column_index/merge/stacked.rs","lineNumber":185,"sourceCode":"}\n\nimpl<'a> Iterable<RowId> for StackedOptionalIndex<'a> {\n    fn boxed_iter(&self) -> Box<dyn Iterator<Item = RowId> + 'a> {\n        Box::new(\n            self.columns\n                .iter()\n                .enumerate()\n                .flat_map(|(columnar_id, column_index_opt)| {\n                    let columnar_row_range = self.stack_merge_order.columnar_range(columnar_id);\n                    let rows_it: Box<dyn Iterator<Item = RowId>> = match column_index_opt {\n                        ColumnIndex::Full => Box::new(columnar_row_range),\n                        ColumnIndex::Optional(optional_index) => Box::new(\n                            optional_index\n                                .iter_non_null_docs()\n                                .map(move |row_id: RowId| columnar_row_range.start + row_id),\n                        ),\n                        ColumnIndex::Multivalued(_) => {\n                            panic!(\"No multivalued index is allowed when stacking column index\");\n                        }\n                        ColumnIndex::Empty { .. } => Box::new(std::iter::empty()),\n                    };\n                    rows_it\n                }),\n        )\n    }\n}\n","sourceCodeStart":167,"sourceCodeEnd":194,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/columnar/src/column_index/merge/stacked.rs#L167-L194","documentation":"When stacking (merging) columnar column indexes, the code can only handle Optional (single-valued) and Empty indexes. If a Multivalued column index is encountered it cannot be expressed as a flat row iterator, so the library panics. This is an internal invariant violation: a multivalued column reached a merge path that only supports single-valued columns.","triggerScenarios":"Calling columnar stack/merge APIs (e.g. stacking columns via Column::merge / stacked column building) on a column whose ColumnIndex is ColumnIndex::Multivalued; i.e. merging a multivalued (array) column through the stacked column-index merge path in columnar/src/column_index/merge/stacked.rs.","commonSituations":"Merging or stacking segments/tables that contain array (multivalued) fields; passing a column built from repeated values into an API documented for single-valued columns; custom tooling that iterates all columns of a table and stacks them without filtering column type (multivalued => Cardinality::Multivalued).","solutions":["Do not stack/merge multivalued columns with this API; check column cardinality first and skip or handle multivalued columns separately.","Use the multivalued-aware merge path (e.g. merging full columns with Column::merge, which handles multivalued indexes) instead of the stacked index merge.","If this is unexpected, verify the column's index type with a debug assert and report a bug to tantivy-columnar maintainers with the segment data."],"exampleFix":"// before\nfor column in columns {\n    stacked.push(column.stack(other)); // panics on multivalued\n}\n// after\nfor column in columns {\n    if column.get_cardinality() != Cardinality::Multivalued {\n        stacked.push(column.stack(other));\n    } else {\n        // handle multivalued columns via the full-column merge API\n        merged_multivalued.push(Column::merge(column.clone(), other.clone()));\n    }\n}","handlingStrategy":"validation","validationCode":"if column.get_cardinality() == Cardinality::Multivalued {\n    return Err(\"cannot stack multivalued column\".into());\n}\nstacked.push(column.stack(other));","typeGuard":"fn is_stackable(card: Cardinality) -> bool {\n    matches!(card, Cardinality::Optional | Cardinality::Full)\n}","tryCatchPattern":null,"preventionTips":["Check column cardinality before any stack/merge call","Route multivalued columns to the multivalued-aware merge API","Log/skip unsupported column types when iterating table columns"],"tags":["panic","columnar","merge","multivalued","invariant-violation"],"backgroundTag":"unsupported-column-cardinality-merge","analyzedSha":"b5d8deb80c26924e6b007a5b1a7630f35ca64de4","analyzedAt":"2026-09-05T13:20:51.521Z","contentChangedAt":"2026-09-05T13:20:51.521Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}