{"record":{"id":"95c2958e47df8b12","repo":"influxdata/influxdb","slug":"key-column-must-be-string-int-uint-or-bool-types-got-column","errorCode":null,"errorMessage":"key column must be string, int, uint, or bool types, got: {column_type}","messagePattern":"key column must be string, int, uint, or bool types, got: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_cache/src/last_cache/mod.rs","lineNumber":30,"sourceCode":"pub use table_function::{LAST_CACHE_UDTF_NAME, LastCacheFunction};\n\n#[derive(Debug, thiserror::Error)]\npub enum Error {\n    #[error(\"invalid cache size\")]\n    InvalidCacheSize,\n    #[error(\n        \"last cache already exists for database and table, but it was configured differently: {reason}\"\n    )]\n    CacheAlreadyExists { reason: String },\n    #[error(\"specified column (name: {column_name}) does not exist in the table definition\")]\n    ColumnDoesNotExistByName { column_name: String },\n    #[error(\"specified column (id: {column_id}) does not exist in the table definition\")]\n    ColumnDoesNotExistById { column_id: ColumnId },\n    #[error(\"specified key column (id: {column_id}) does not exist in the table schema\")]\n    KeyColumnDoesNotExist { column_id: ColumnId },\n    #[error(\"specified key column (name: {column_name}) does not exist in the table schema\")]\n    KeyColumnDoesNotExistByName { column_name: String },\n    #[error(\"key column must be string, int, uint, or bool types, got: {column_type}\")]\n    InvalidKeyColumn { column_type: InfluxColumnType },\n    #[error(\"specified value column ({column_id}) does not exist in the table schema\")]\n    ValueColumnDoesNotExist { column_id: ColumnId },\n    #[error(\"requested last cache does not exist\")]\n    CacheDoesNotExist,\n}\n\nimpl Error {\n    fn cache_already_exists(reason: impl Into<String>) -> Self {\n        Self::CacheAlreadyExists {\n            reason: reason.into(),\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests;\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_cache/src/last_cache/mod.rs#L12-L48","documentation":"This is the `InvalidKeyColumn` variant of the last-cache `Error` enum. Last-of-value cache key columns must be string, int, uint, or bool (tag-like, groupable types); it is raised when a column designated as a key column has an unsupported InfluxColumnType such as float or timestamp. The type check happens against the table schema at cache creation.","triggerScenarios":"Calling `create_last_cache` with a `key_columns` entry that resolves to a float or time column in the table schema; using a measurement/value field as a group-by key for the cache.","commonSituations":"Configuring a numeric measurement field (e.g. a float 'value' column) as a cache key; switching a column's type in the schema after the cache config was written; misunderstanding that key columns must be tag-like, not values.","solutions":["Choose a string/int/uint/bool column (typically a tag) as the key column","Remove the unsupported column from `key_columns` and key the cache by tags only","If the offending column must be a key, change its schema type to an allowed one and recreate the table/cache"],"exampleFix":"// before\n// 'temperature' is a float field -> InvalidKeyColumn\ncreate_last_cache(db, \"sensors\", \"latest\", Some(&[\"location\", \"temperature\"]), None, 10, None);\n// after\ncreate_last_cache(db, \"sensors\", \"latest\", Some(&[\"location\"]), None, 10, None);","handlingStrategy":"validation","validationCode":"fn key_columns_have_allowed_type(schema: &Schema, names: &[&str]) -> Result<(), String> {\n    for n in names {\n        let id = schema.field_name_to_id(n)?;\n        let t = schema.field_type_by_id(id).unwrap();\n        if !matches!(t,\n            InfluxColumnType::Tag\n            | InfluxColumnType::Field(FieldType::Int)\n            | InfluxColumnType::Field(FieldType::UInt)\n            | InfluxColumnType::Field(FieldType::Boolean))\n        {\n            return Err(format!(\"key column '{n}' has unsupported type {t:?}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_valid_key_type(t: &InfluxColumnType) -> bool {\n    matches!(t,\n        InfluxColumnType::Tag\n        | InfluxColumnType::Field(FieldType::Int)\n        | InfluxColumnType::Field(FieldType::UInt)\n        | InfluxColumnType::Field(FieldType::Boolean))\n}","tryCatchPattern":"match res {\n    Err(LastCacheError::InvalidKeyColumn { column_type }) => {\n        eprintln!(\"key column type {column_type} unsupported; use string/int/uint/bool\");\n    }\n    Err(e) => return Err(e.into()),\n    Ok(_) => {}\n}","preventionTips":["Inspect column types in the table schema before choosing key columns","Key caches only on tag columns, which are always valid","Re-check types after schema migrations that may change a column's type"],"tags":["influxdb3","last-cache","key-column","type-constraint"],"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"}