{"record":{"id":"949cff9359142ab6","repo":"quickwit-oss/tantivy","slug":"invalidinput","errorCode":"InvalidInput","errorMessage":"Required column conflicts with another required column of the same type category.","messagePattern":"Required column conflicts with another required column of the same type category\\.","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"columnar/src/columnar/merge/mod.rs","lineNumber":318,"sourceCode":"            required_column_type: self.required_column_type,\n            columns,\n        })\n    }\n\n    /// Set the dynamic column for a given columnar.\n    fn set_column(&mut self, columnar_id: usize, column: DynamicColumnHandle) {\n        self.columns[columnar_id] = Some(column);\n    }\n\n    /// Force the existence of a column, as well as its type.\n    fn require_type(&mut self, required_type: ColumnType) -> io::Result<()> {\n        if let Some(existing_required_type) = self.required_column_type {\n            if existing_required_type == required_type {\n                // This was just a duplicate in the `required_columns`.\n                // Nothing to do.\n                return Ok(());\n            } else {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"Required column conflicts with another required column of the same type \\\n                     category.\",\n                ));\n            }\n        }\n        self.required_column_type = Some(required_type);\n        Ok(())\n    }\n}\n\n/// Returns the type of the merged numerical column.\n///\n/// This function picks the first numerical type out of i64, u64, f64 (order matters\n/// here), that is compatible with all the `columns`.\n///\n/// # Panics\n/// Panics if one of the column is not numerical.","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/columnar/src/columnar/merge/mod.rs#L300-L336","documentation":"During a columnar merge, require_type records a per-column required type. If the same column name is required twice with different types in the same type category (both numeric, for instance), the merge cannot satisfy both and raises InvalidInput. Duplicate identical requirements are allowed; only conflicting ones fail.","triggerScenarios":"Building a merge mapping where require_type (or the higher-level API taking required_columns) is given the same column name with two different required types from the same category, e.g. u64 for one field usage and i64 for another.","commonSituations":"Merging schemas where one field was redefined between generations (u64 -> i64); programmatic merge mapping built by hand with duplicated column names; schema migration where a stored column and a fast field requirement disagree.","solutions":["Ensure each column name appears at most once in the required-columns mapping, with a single consistent type","Fix the schema so the column's type is the same across all merged segments","Drop the conflicting requirement for one usage and rely on auto-detected types","Detect the conflict before merging by comparing required types per column and erroring with a clearer message"],"exampleFix":"// before\nmap.require_type(\"score\", ColumnType::U64);\nmap.require_type(\"score\", ColumnType::I64); // conflict\n// after\nmap.require_type(\"score\", ColumnType::U64);","handlingStrategy":"validation","validationCode":"fn check_required_types(reqs: &[(String, ColumnType)]) -> Option<String> {\n    let mut seen: std::collections::HashMap<&str, ColumnType> = Default::default();\n    for (name, ty) in reqs {\n        if let Some(prev) = seen.get(name.as_str()) {\n            if *prev != *ty { return Some(name.clone()); }\n        } else { seen.insert(name.as_str(), *ty); }\n    }\n    None\n}\n// guard: if let Some(c) = check_required_types(&reqs) { fix mapping for c; }","typeGuard":null,"tryCatchPattern":"if let Err(e) = merge_mapping.build() {\n    if e.kind() == io::ErrorKind::InvalidInput && e.to_string().contains(\"Required column conflicts\") {\n        // deduplicate requirements per column name and retry\n    } else { return Err(e); }\n}","preventionTips":["One required type per column name; dedupe mappings before merge","Keep schemas consistent across merged segments","Diff old vs new schemas when fields are redefined","Add a pre-merge schema validation step"],"tags":["schema","merge","columnar","conflict"],"backgroundTag":"column-type-conflict","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"}