{"record":{"id":"488d8992b8dde6e0","repo":"influxdata/influxdb","slug":"time-column-was-an-unexpected-type","errorCode":null,"errorMessage":"time column was an unexpected type","messagePattern":"time column was an unexpected type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/partition/src/traits/record_batch.rs","lineNumber":71,"sourceCode":"    type Column = Arc<dyn Array>;\n\n    fn num_rows(&self) -> usize {\n        self.num_rows()\n    }\n\n    fn column(&self, column: &str) -> Option<&Self::Column> {\n        self.column_by_name(column)\n    }\n\n    fn time_column(&self) -> Result<&[i64], TimeColumnError> {\n        let time_column = self\n            .column_by_name(TIME_COLUMN_NAME)\n            .ok_or(TimeColumnError::NotFound)?;\n\n        Ok(time_column\n            .as_any()\n            .downcast_ref::<TimestampNanosecondArray>()\n            .expect(\"time column was an unexpected type\")\n            .values()\n            .inner()\n            .typed_data())\n    }\n}\n","sourceCodeStart":53,"sourceCodeEnd":77,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/partition/src/traits/record_batch.rs#L53-L77","documentation":"expect(\"time column was an unexpected type\") panic in RecordBatch::time_column: the batch was found to contain a column named 'time', but downcast_ref::<TimestampNanosecondArray>() failed, meaning the time column exists yet is not a Timestamp(Nanosecond) arrow array. The method guarantees returning &[i64] nanosecond values, so any other physical type is treated as unrecoverable.","triggerScenarios":"Calling time_column() on a RecordBatch whose TIME_COLUMN_NAME column holds Int64, Timestamp(Millisecond/Microsecond/Second), or another type instead of Timestamp(Nanosecond, None).","commonSituations":"Batches built from parquet/CSV where the time column was inferred as Int64, query planners that cast timestamps to coarser units, or older writers that stored seconds/micros.","solutions":["Ensure the time column is created as TimestampNanosecondArray (DataType::Timestamp(Nanosecond, None))","Cast/convert other timestamp units to nanoseconds before handing the batch to the partition code","Replace expect() with a Result returning TimeColumnError for graceful degradation","Validate the batch schema (time column datatype) before calling time_column()"],"exampleFix":"// before\n.expect(\"time column was an unexpected type\")\n// after\n.ok_or(TimeColumnError::UnexpectedType(time_column.data_type().clone()))?","handlingStrategy":"type-guard","validationCode":"// rust\nlet is_ns_ts = matches!(time_column.data_type(),\n    DataType::Timestamp(arrow::datatypes::TimeUnit::Nanosecond, _));","typeGuard":"// rust\nfn as_ns_timestamps<'a>(a: &'a dyn Array) -> Option<&'a TimestampNanosecondArray> {\n    a.as_any().downcast_ref::<TimestampNanosecondArray>()\n}","tryCatchPattern":"let ts = time_column.as_any().downcast_ref::<TimestampNanosecondArray>()\n    .ok_or(TimeColumnError::UnexpectedType(time_column.data_type().clone()))?;","preventionTips":["Cast time columns to Timestamp(Nanosecond) before passing batches to partitioning","Validate the batch schema's time column datatype as an entry precondition","Return Result instead of expect() for arrays produced outside this crate"],"tags":["rust","panic","downcast","arrow","timestamp"],"backgroundTag":"type-mismatch","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"}