{"record":{"id":"90320ae88b88a6e3","repo":"risingwavelabs/risingwave","slug":"failed-to-parse-the-interval","errorCode":null,"errorMessage":"failed to parse the interval","messagePattern":"failed to parse the interval","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/utils.rs","lineNumber":562,"sourceCode":"                    }\n                })??\n            } else {\n                date_time.timestamp_tz()\n            }\n        }\n        AsOf::VersionNum(_) | AsOf::VersionString(_) => {\n            return Err(ErrorCode::NotSupported(\n                \"AS OF VERSION is not supported\".to_owned(),\n                \"please use AS OF TIMESTAMP\".to_owned(),\n            )\n            .into());\n        }\n        AsOf::ProcessTimeWithInterval((value, leading_field)) => {\n            let interval = Interval::parse_with_fields(\n                value,\n                Some(crate::Binder::bind_date_time_field(*leading_field)),\n            )\n            .map_err(|_| anyhow!(\"failed to parse the interval\"))?;\n            let interval_sec = (interval.epoch_in_micros() / 1_000_000) as i64;\n            chrono::Utc::now()\n                .timestamp()\n                .checked_sub(interval_sec)\n                .ok_or_else(|| anyhow!(\"invalid timestamp\"))?\n        }\n    };\n    Ok(Some(PbBatchQueryEpoch {\n        epoch: Some(batch_query_epoch::PbEpoch::TimeTravel(\n            unix_timestamp_sec_to_epoch(timestamp).0,\n        )),\n    }))\n}\n\npub fn to_iceberg_time_travel_as_of(\n    a: &Option<AsOf>,\n    timezone: &String,\n) -> Result<Option<IcebergTimeTravelInfo>> {","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/utils.rs#L544-L580","documentation":"For AS OF PROCESS TIME WITH INTERVAL clauses, to_batch_query_epoch parses the interval string with Interval::parse_with_fields using the declared leading field. If the string is not a valid interval for that field, the error is masked with this generic \"failed to parse the interval\" message.","triggerScenarios":"A time travel query like `... AS OF PROCESS TIME WITH INTERVAL 'xyz' DAY` where the interval literal fails Interval::parse_with_fields for the given leading field.","commonSituations":"Malformed interval literals (non-numeric text, wrong units for the leading field, e.g. '1 hour' when the leading field is DAY), quotes or whitespace issues in generated SQL.","solutions":["Use a valid interval literal compatible with the leading field, e.g. INTERVAL '1' DAY.","Match the leading field to the unit in the value (e.g. WITH INTERVAL '2' HOUR for hours).","Escape/quote the interval correctly in the SQL-generating code."],"exampleFix":"// before\nAS OF PROCESS TIME WITH INTERVAL 'yesterday' DAY\n// after\nAS OF PROCESS TIME WITH INTERVAL '1' DAY","handlingStrategy":"validation","validationCode":"// validate interval literal against leading field before query\nlet (value, field) = (\"1\", \"DAY\");\nassert!(value.chars().all(|c| c.is_ascii_digit() || c == ' '), \"interval value must be numeric\");","typeGuard":"fn is_numeric_interval(v: &str) -> bool { !v.trim().is_empty() && v.trim().chars().all(|c| c.is_ascii_digit() || c == '.' ) }","tryCatchPattern":"match res {\n    Err(e) if e.to_string().contains(\"failed to parse the interval\") => eprintln!(\"use a numeric interval literal matching the leading field, e.g. INTERVAL '1' DAY\"),\n    other => other?,\n}","preventionTips":["Always use numeric interval values quoted per SQL standard: INTERVAL '1' DAY.","Keep leading field consistent with the value's unit.","Sanitize user-supplied durations before interpolating into SQL."],"tags":["sql","time-travel","interval-parsing"],"backgroundTag":"invalid-argument-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"}