{"record":{"id":"366816510067d08c","repo":"risingwavelabs/risingwave","slug":"failed-to-parse-the-timestamp","errorCode":null,"errorMessage":"failed to parse the timestamp","messagePattern":"failed to parse the timestamp","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/utils.rs","lineNumber":524,"sourceCode":"}\n\npub fn to_batch_query_epoch(a: &Option<AsOf>) -> Result<Option<PbBatchQueryEpoch>> {\n    let Some(a) = a else {\n        return Ok(None);\n    };\n    Feature::TimeTravel.check_available()?;\n    let timestamp = match a {\n        AsOf::ProcessTime | AsOf::ProcessTimeBroadcast => {\n            return Err(ErrorCode::NotSupported(\n                \"AS OF PROCTIME is not supported\".to_owned(),\n                \"please use AS OF TIMESTAMP\".to_owned(),\n            )\n            .into());\n        }\n        AsOf::TimestampNum(ts) => *ts,\n        AsOf::TimestampString(ts) => {\n            let date_time = speedate::DateTime::parse_str_rfc3339(ts)\n                .map_err(|_e| anyhow!(\"failed to parse the timestamp\"))?;\n            if date_time.time.tz_offset.is_none() {\n                // If the input does not specify a time zone, use the time zone set by the \"SET TIME ZONE\" command.\n                risingwave_expr::expr_context::TIME_ZONE::try_with(|set_time_zone| {\n                    let tz =\n                        Timestamptz::lookup_time_zone(set_time_zone).map_err(|e| anyhow!(e))?;\n                    match tz.with_ymd_and_hms(\n                        date_time.date.year.into(),\n                        date_time.date.month.into(),\n                        date_time.date.day.into(),\n                        date_time.time.hour.into(),\n                        date_time.time.minute.into(),\n                        date_time.time.second.into(),\n                    ) {\n                        MappedLocalTime::Single(d) => Ok(d.timestamp()),\n                        MappedLocalTime::Ambiguous(_, _) | MappedLocalTime::None => {\n                            Err(anyhow!(format!(\n                                \"failed to parse the timestamp {ts} with the specified time zone {tz}\"\n                            )))","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/utils.rs#L506-L542","documentation":"In to_batch_query_epoch, when an AS OF time travel clause uses a timestamp string (AsOf::TimestampString), it is parsed with speedate's RFC3339 parser. If the string is not valid RFC3339, the parse error is replaced with this generic \"failed to parse the timestamp\" error.","triggerScenarios":"Executing a time travel query such as `SELECT ... FROM t AS OF TIMESTAMP 'not-a-date'` where the string fails speedate::DateTime::parse_str_rfc3339; also via lookup join AS OF or vector index nearest AS OF clauses that carry a TimestampString.","commonSituations":"Typos or non-RFC3339 formats like '2024-01-01 10:00:00' (space instead of T), locale-formatted dates, or Unix epoch numbers quoted as strings.","solutions":["Rewrite the AS OF timestamp as a valid RFC3339 string, e.g. '2024-01-01T10:00:00Z'.","Use AS OF TIMESTAMP with a numeric epoch value (AsOf::TimestampNum) instead of a string.","Check the application code generating the timestamp to ensure it emits RFC3339 with offset."],"exampleFix":"// before\nSELECT * FROM t AS OF TIMESTAMP '2024/01/01 10:00';\n// after\nSELECT * FROM t AS OF TIMESTAMP '2024-01-01T10:00:00Z';","handlingStrategy":"validation","validationCode":"// client-side check before issuing time travel query\nlet ts = \"2024-01-01T10:00:00Z\";\nassert!(chrono::DateTime::parse_from_rfc3339(ts).is_ok(), \"AS OF TIMESTAMP must be RFC3339\");","typeGuard":"fn is_rfc3339(s: &str) -> bool { chrono::DateTime::parse_from_rfc3339(s).is_ok() }","tryCatchPattern":"match res {\n    Err(e) if e.to_string().contains(\"failed to parse the timestamp\") => eprintln!(\"AS OF TIMESTAMP must be an RFC3339 string, e.g. 2024-01-01T10:00:00Z\"),\n    other => other?,\n}","preventionTips":["Always emit RFC3339 (with T separator and offset) for AS OF TIMESTAMP strings.","Prefer numeric epoch AS OF values to avoid string parsing entirely.","Validate timestamps in the SQL-generating layer before execution."],"tags":["sql","time-travel","timestamp-parsing"],"backgroundTag":"invalid-date-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}