influxdata/influxdb · error

time column was an unexpected type

Error message

time column was an unexpected type

What it means

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.

Solutions

  1. Ensure the time column is created as TimestampNanosecondArray (DataType::Timestamp(Nanosecond, None))
  2. Cast/convert other timestamp units to nanoseconds before handing the batch to the partition code
  3. Replace expect() with a Result returning TimeColumnError for graceful degradation
  4. Validate the batch schema (time column datatype) before calling time_column()

Example fix

// before
.expect("time column was an unexpected type")
// after
.ok_or(TimeColumnError::UnexpectedType(time_column.data_type().clone()))?
Defensive patterns

Strategy: type-guard

Validate before calling

// rust
let is_ns_ts = matches!(time_column.data_type(),
    DataType::Timestamp(arrow::datatypes::TimeUnit::Nanosecond, _));

Type guard

// rust
fn as_ns_timestamps<'a>(a: &'a dyn Array) -> Option<&'a TimestampNanosecondArray> {
    a.as_any().downcast_ref::<TimestampNanosecondArray>()
}

Try / catch

let ts = time_column.as_any().downcast_ref::<TimestampNanosecondArray>()
    .ok_or(TimeColumnError::UnexpectedType(time_column.data_type().clone()))?;

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/488d8992b8dde6e0. Report an issue: GitHub.

Appendix: source

Thrown at core/partition/src/traits/record_batch.rs:71

    type Column = Arc<dyn Array>;

    fn num_rows(&self) -> usize {
        self.num_rows()
    }

    fn column(&self, column: &str) -> Option<&Self::Column> {
        self.column_by_name(column)
    }

    fn time_column(&self) -> Result<&[i64], TimeColumnError> {
        let time_column = self
            .column_by_name(TIME_COLUMN_NAME)
            .ok_or(TimeColumnError::NotFound)?;

        Ok(time_column
            .as_any()
            .downcast_ref::<TimestampNanosecondArray>()
            .expect("time column was an unexpected type")
            .values()
            .inner()
            .typed_data())
    }
}

View on GitHub (pinned to 06200ef96b)