{"record":{"id":"b9fb2dd9421cc2f9","repo":"influxdata/influxdb","slug":"specified-column-id-column-id-does-not-exist-in-the-table","errorCode":null,"errorMessage":"specified column (id: {column_id}) does not exist in the table definition","messagePattern":"specified column \\(id: (.+?)\\) does not exist in the table definition","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_cache/src/last_cache/mod.rs","lineNumber":24,"sourceCode":"pub use cache::CreateLastCacheArgs;\nmod metrics;\nmod provider;\npub use provider::{LastCacheProvider, background_catalog_update};\nmod table_function;\nuse schema::InfluxColumnType;\npub 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        }","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_cache/src/last_cache/mod.rs#L6-L42","documentation":"This is the `ColumnDoesNotExistById` variant of the last-cache `Error` enum in influxdb3_cache. It is raised when a last-of-value cache is being created or configured with a column referenced by its numeric ColumnId that is not present in the table's schema definition. The cache layer validates every referenced column against the current table definition before building the cache, and fails fast when the id resolves to no column.","triggerScenarios":"Calling `LastCacheProvider::create_last_cache` (or create_from_table) with a `value_columns` list or column configuration containing a ColumnId that is not in the table schema; passing a stale ColumnId captured from an older schema version after the table's columns were re-created with new ids.","commonSituations":"Referencing column ids from cached/outdated schema metadata after a `CREATE TABLE` or `ALTER TABLE` re-created the table; copying hard-coded column ids between environments whose schemas differ; mixing up ColumnId with column name in cache configuration code.","solutions":["Print the table schema (e.g. via `information_schema` or the table's `Schema`) and use column NAMES instead of ids when configuring the last cache","Refresh the ColumnId from the current schema — get it by name via the table definition before building the cache","Re-run schema discovery after any ALTER TABLE so captured ids are not stale"],"exampleFix":"// before\nlet col_id: ColumnId = 7; // stale id from old schema\nlet cfg = LastCacheConfig::new(name, count, ttl, key_cols, vec![col_id]);\n// after\nlet col_id = table_def.schema().column_id_by_name(\"temperature\")\n    .expect(\"column 'temperature' exists in table definition\");\nlet cfg = LastCacheConfig::new(name, count, ttl, key_cols, vec![col_id]);","handlingStrategy":"validation","validationCode":"fn validate_value_column(schema: &Schema, col_id: ColumnId) -> Result<(), String> {\n    schema.field_id(col_id)\n        .map(|_| ())\n        .ok_or_else(|| format!(\"column id {col_id} not found in table schema\"))\n}","typeGuard":"fn column_exists(schema: &Schema, col_id: ColumnId) -> bool {\n    schema.field_id(col_id).is_some()\n}","tryCatchPattern":"match provider.create_last_cache(&db_name, &tbl_name, cfg) {\n    Err(LastCacheError::ColumnDoesNotExistById { column_id }) => {\n        eprintln!(\"cache references unknown column id {column_id}; refresh schema and retry\");\n    }\n    Err(e) => return Err(e.into()),\n    Ok(_) => {}\n}","preventionTips":["Always resolve column ids from the live schema immediately before cache creation","Use column names in configuration and convert to ids at the last moment","Re-generate cache configs after any ALTER TABLE or table recreation"],"tags":["influxdb3","last-cache","schema","column-not-found"],"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"}