{"record":{"id":"4ea7f314adca2e45","repo":"nautechsystems/nautilus_trader","slug":"ts-init-column-not-found","errorCode":null,"errorMessage":"ts_init column not found","messagePattern":"ts_init column not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/persistence/src/backend/catalog.rs","lineNumber":3881,"sourceCode":"        if convert_bar_type_to_external {\n            convert_bar_type_metadata_to_external(&mut metadata);\n        }\n\n        let mut all_data = Vec::new();\n\n        for mut batch in batches {\n            if use_ts_event_for_ts_init {\n                let column_names: Vec<String> =\n                    schema.fields().iter().map(|f| f.name().clone()).collect();\n\n                let ts_event_idx = column_names\n                    .iter()\n                    .position(|n| n == \"ts_event\")\n                    .ok_or_else(|| anyhow::anyhow!(\"ts_event column not found\"))?;\n                let ts_init_idx = column_names\n                    .iter()\n                    .position(|n| n == \"ts_init\")\n                    .ok_or_else(|| anyhow::anyhow!(\"ts_init column not found\"))?;\n\n                let mut new_columns = batch.columns().to_vec();\n                new_columns[ts_init_idx] = new_columns[ts_event_idx].clone();\n\n                batch = RecordBatch::try_new(schema.clone(), new_columns)\n                    .map_err(|e| anyhow::anyhow!(\"Failed to create new batch: {e}\"))?;\n            }\n\n            let data_vec = T::decode_data_batch(&metadata, batch)\n                .map_err(|e| anyhow::anyhow!(\"Failed to decode batch: {e}\"))?;\n\n            all_data.extend(data_vec);\n        }\n\n        Ok(to_variant::<T>(all_data))\n    }\n\n    /// Converts `RecordBatches` directly to strongly typed values.","sourceCodeStart":3863,"sourceCodeEnd":3899,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/persistence/src/backend/catalog.rs#L3863-L3899","documentation":"Raised in `convert_record_batches_to_data_with_bar_type_conversion` when `use_ts_event_for_ts_init` is true but the record-batch schema has no `ts_init` column, so the destination column of the `ts_event → ts_init` copy cannot be found. Decoding expects `ts_init` to be present, so the transform cannot proceed.","triggerScenarios":"Same conversion paths as the `ts_event` variant: enabling `use_ts_event_for_ts_init` on batches whose schema lacks `ts_init` — legacy files, custom data without timestamp columns, or a mismatched data_cls selecting the wrong files.","commonSituations":"Reading old stream files written before `ts_init` was standardized; hand-crafted or externally produced Arrow files missing the `ts_init` field; requesting the conversion for a data type whose decoder schema omits `ts_init`.","solutions":["Inspect the file's schema field names and confirm `ts_init` is present; re-write the file with the current writer if not.","Disable the transform by calling the reader with `use_ts_event_for_ts_init=false` when the data type does not need the ts_event→ts_init copy.","Correct the data_cls or identifier filter so only files with the expected schema are converted.","If the files are custom data, re-register the type with a schema containing `ts_init` and rewrite the data."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn has_required_ts_columns(schema: &Schema) -> bool {\n    schema.field_with_name(\"ts_event\").is_ok() && schema.field_with_name(\"ts_init\").is_ok()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check both ts_event and ts_init exist in the file schema before requesting the transform.","Re-write legacy files lacking ts_init with the current writer.","Match the data_cls precisely so only schema-complete files are converted.","Document per-data-class schema requirements for teams writing external feather files."],"tags":["arrow","schema","timestamp","persistence"],"backgroundTag":"schema-validation-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}