{"record":{"id":"cf3115732dfd7a47","repo":"risingwavelabs/risingwave","slug":"time-travel-is-not-supported-for-the-source","errorCode":null,"errorMessage":"Time travel is not supported for the source","messagePattern":"Time travel is not supported for the source","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/logical_source.rs","lineNumber":92,"sourceCode":"        as_of: Option<AsOf>,\n    ) -> Result<Self> {\n        // XXX: should we reorder the columns?\n        // The order may be strange if the schema is changed, e.g., [foo:Varchar, _rw_kafka_timestamp:Timestamptz, _row_id:Serial, bar:Int32]\n        // related: https://github.com/risingwavelabs/risingwave/issues/16486\n        // The order does not matter much. The columns field is essentially a map indexed by the column id.\n        // It will affect what users will see in `SELECT *`.\n        // But not sure if we rely on the position of hidden column like `_row_id` somewhere. For `projected_row_id` we do so...\n        let core = generic::Source {\n            catalog: source_catalog,\n            column_catalog,\n            row_id_index,\n            kind,\n            ctx,\n            as_of,\n        };\n\n        if core.as_of.is_some() && !core.support_time_travel() {\n            bail!(\"Time travel is not supported for the source\")\n        }\n\n        let base = PlanBase::new_logical_with_core(&core);\n\n        let output_exprs = Self::derive_output_exprs_from_generated_columns(&core.column_catalog)?;\n        let (core, output_row_id_index) = core.exclude_generated_columns();\n\n        Ok(LogicalSource {\n            base,\n            core,\n            output_exprs,\n            output_row_id_index,\n        })\n    }\n\n    pub fn with_catalog(\n        source_catalog: Rc<SourceCatalog>,\n        kind: SourceNodeKind,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/logical_source.rs#L74-L110","documentation":"Creating a `LogicalSource` fails with `bail!` when the source is created with an `AS OF` (time travel) clause but the source kind does not support time travel (its `support_time_travel()` returns false). This is a user-facing validation error raised at plan construction, e.g. for sources (like certain CDC or shared sources) whose snapshot/history cannot be queried at a past timestamp.","triggerScenarios":"Executing `SELECT ... FROM <source> FOR SYSTEM_TIME AS OF <timestamp>` (or creating a materialized view with such time travel) where `<source>` is a source whose `support_time_travel()` is false (e.g. a shared source / non-table source without time-travel support).","commonSituations":"Users try flashback/as-of queries against a source (not a table/DML-tail-supported relation), or after a version change enabled time travel only for some source kinds; also occurs when scripting generic time-travel queries across all relations.","solutions":["Remove the `FOR SYSTEM_TIME AS OF ...` / time travel clause and query the source's current stream instead.","Use a table (or a source kind that supports time travel) if historical point-in-time reads are required.","Backfill the needed history into a table, then apply AS OF against that table.","Check RisingWave docs/version for which source kinds support time travel and upgrade if support was added later."],"exampleFix":"// before\nSELECT * FROM my_source FOR SYSTEM_TIME AS OF '2026-01-01 00:00:00';\n// after\nSELECT * FROM my_source; -- time travel unsupported for sources\n","handlingStrategy":"validation","validationCode":"// Check relation kind before issuing a time-travel query.\nlet kind = rw.describe(\"my_source\")?.kind;\nif kind != RelationKind::Table {\n    return Err(\"time travel requires a table, not a source\");\n}\n// then it is safe to add: FOR SYSTEM_TIME AS OF <ts>","typeGuard":"fn supports_time_travel(kind: RelationKind) -> bool {\n    matches!(kind, RelationKind::Table | RelationKind::DmlTailSupportedTable)\n}","tryCatchPattern":"match err.message.contains(\"Time travel is not supported\") {\n    true => fallback_to_current_scan(sql_without_as_of),\n    false => return Err(err),\n}","preventionTips":["Only apply FOR SYSTEM_TIME AS OF to tables, not to sources.","Check the relation type via catalog/describe before generating as-of queries.","For historical reads on sources, first backfill into a table.","Keep generation code that adds time travel opt-in per relation kind."],"tags":["sql","time-travel","source","validation","as-of"],"backgroundTag":"unsupported-operation","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}