{"record":{"id":"dd48879b7c7361d6","repo":"influxdata/influxdb","slug":"duplicate-column-name-column","errorCode":null,"errorMessage":"duplicate column name: {column}","messagePattern":"duplicate column name: (.+?)","errorType":"error_code","errorClass":"Error::DuplicateColumnName","httpStatus":null,"severity":"error","filePath":"core/mutable_batch_pb/src/decode.rs","lineNumber":100,"sourceCode":"    if to_insert == 0 {\n        return Ok(());\n    }\n\n    // Verify columns are unique\n    let mut columns: Vec<&str> = table_batch\n        .columns\n        .iter()\n        .map(|c| c.column_name.as_str())\n        .collect();\n    columns.sort_unstable();\n\n    let mut found_time = columns.first().is_some_and(|f| *f == TIME_COLUMN_NAME);\n\n    // it would be nice to use `array_windows` here but alas, that's nightly-only\n    for two_names in columns.windows(2) {\n        let first = two_names[0];\n        let second = two_names[1];\n        ensure!(\n            first != two_names[1],\n            DuplicateColumnNameSnafu { column: first }\n        );\n\n        found_time |= second == TIME_COLUMN_NAME;\n    }\n\n    ensure!(found_time, MissingTimeSnafu);\n\n    let mut writer = Writer::new(batch, to_insert);\n    for column in &table_batch.columns {\n        let influx_type = pb_column_type(column)?;\n        let valid_mask = compute_valid_mask(&column.null_mask, to_insert);\n        let valid_mask = valid_mask.as_deref();\n\n        // Already verified has values\n        let values = column.values.as_ref().unwrap();\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/mutable_batch_pb/src/decode.rs#L82-L118","documentation":"DuplicateColumnNameSnafu is raised by write_table_batch in mutable_batch_pb when decoding a WriteTableBatch protobuf: two adjacent columns in the batch share the same name. The decoder walks the column list with a 2-wide window and rejects any duplicate, because a table batch must have unique column names to build a valid MutableBatch. The duplicate name is embedded in the message.","triggerScenarios":"Calling write_table_batch (directly or via decode_database_batch / the write path's run) on a protobuf WriteTableBatch whose `columns` list contains two entries with an identical column_name.","commonSituations":"A producer bug appending the same column twice when building the LP/protobuf payload; merging two row entries without deduplicating fields; schema drift where a tag and field were given the same name.","solutions":["Deduplicate columns by name in the client/producer before sending the WriteTableBatch","Reject or log the payload upstream with the duplicated column name from the error message","Add a producer-side schema check that tag and field names are distinct per line/row"],"exampleFix":"// before\nbatch.columns.push(col_timestamp);\nbatch.columns.push(col_timestamp); // duplicate\n// after\nlet seen: HashSet<&str> = HashSet::new();\nif !seen.insert(col_timestamp.column_name.as_str()) { /* skip or error */ }\nbatch.columns.push(col_timestamp);","handlingStrategy":"validation","validationCode":"fn has_duplicate_columns(names: &[&str]) -> bool {\n    names.iter().collect::<std::collections::HashSet<_>>().len() != names.len()\n}\nif has_duplicate_columns(&column_names) { /* reject batch before sending */ }","typeGuard":null,"tryCatchPattern":"match write_table_batch(batch, table_batch) {\n    Err(e) if e.to_string().starts_with(\"duplicate column name\") => /* log offending name and reject payload */,\n    other => other?,\n}","preventionTips":["Deduplicate columns by name on the producer side","Keep tag and field names distinct per measurement","Add round-trip encode/decode tests that assert unique column names"],"tags":["rust","protobuf","decode","duplicate-column","data-write"],"backgroundTag":"schema-validation-failed","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}