risingwavelabs/risingwave · error · InvalidParamsError
Can't cast string to timestamp (expected format is YYYY-MM-D
Error message
Can't cast string to timestamp (expected format is YYYY-MM-DD HH:MM:SS[.D+{up to 9 digits}] or YYYY-MM-DD HH:MM or YYYY-MM-DD or ISO 8601 format) What it means
ErrorKind::ParseTimestamp is thrown by Timestamp::from_str when jiff's civil::DateTime parser rejects the input. Accepted shapes: 'YYYY-MM-DD HH:MM:SS[.up to 9 fractional digits]', 'YYYY-MM-DD HH:MM', 'YYYY-MM-DD', or ISO 8601 ('YYYY-MM-DDTHH:MM:SS').
Source
Thrown at src/common/src/types/datetime.rs:265
#[derive(Copy, Clone, Debug, Error)]
enum ErrorKind {
#[error("Invalid date: days: {days}")]
Date { days: i32 },
#[error("Invalid time: secs: {secs}, nanoseconds: {nsecs}")]
Time { secs: u32, nsecs: u32 },
#[error("Invalid time: {value} {unit} is out of range for a time of day")]
TimeOfDay { value: u64, unit: &'static str },
#[error("Invalid datetime: seconds: {secs}, nanoseconds: {nsecs}")]
DateTime { secs: i64, nsecs: u32 },
#[error("Invalid datetime: {value} {unit} is out of range")]
Timestamp { value: i64, unit: &'static str },
#[error("Can't cast string to date (expected format is YYYY-MM-DD)")]
ParseDate,
#[error(
"Can't cast string to time (expected format is HH:MM:SS[.D+{{up to 6 digits}}][Z] or HH:MM)"
)]
ParseTime,
#[error(
"Can't cast string to timestamp (expected format is YYYY-MM-DD HH:MM:SS[.D+{{up to 9 digits}}] or YYYY-MM-DD HH:MM or YYYY-MM-DD or ISO 8601 format)"
)]
ParseTimestamp,
}
#[derive(Debug, Error)]
#[error(transparent)]
pub struct InvalidParamsError(#[from] ErrorKind);
impl InvalidParamsError {
pub fn date(days: i32) -> Self {
ErrorKind::Date { days }.into()
}
pub fn time(secs: u32, nsecs: u32) -> Self {
ErrorKind::Time { secs, nsecs }.into()
}
View on GitHub (pinned to 6469eb736d)
Solutions
- Convert epoch numbers via Timestamp::with_millis/with_micros instead of string parsing.
- Reformat the string to 'YYYY-MM-DD HH:MM:SS' or ISO 8601 before casting.
- Use an explicit parsing function with a format mask for non-ISO source layouts.
Example fix
// before
let ts = Timestamp::from_str("1705315500000")?;
// after
let ts = Timestamp::with_millis(1705315500000)?; Defensive patterns
Strategy: validation
Validate before calling
fn is_parseable_timestamp(s: &str) -> bool {
let re = regex::Regex::new(r"^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?)?$").unwrap();
re.is_match(s.trim())
} Type guard
fn looks_like_timestamp(s: &str) -> bool {
s.trim().parse::<jiff::civil::DateTime>().is_ok()
} Try / catch
let ts = Timestamp::from_str(s)
.map_err(|e| anyhow!("'{s}' is not a supported timestamp format: {e}"))?; Prevention
- Convert epoch numbers with with_millis/with_micros, never via string parsing.
- Standardize on 'YYYY-MM-DD HH:MM:SS' or ISO 8601 at data entry points.
- Reject locale-formatted dates upstream instead of relying on cast errors.
When it happens
Trigger: Casting strings such as '2024-01-15 04:05:06 PM', '15/01/2024 10:00', or Unix epoch integers to TIMESTAMP; epoch numbers must be converted numerically (with_millis/with_micros), not parsed as strings.
Common situations: CSV ingestion with US-style date ordering; passing epoch milliseconds as string and expecting implicit conversion; locale-specific month names (e.g. 'Jan 15, 2024 10:00').
Related errors
- Can't cast string to date (expected format is YYYY-MM-DD)
- Can't cast string to time (expected format is HH:MM:SS[.D+{u
- Invalid datetime: seconds: {secs}, nanoseconds: {nsecs}
- Invalid datetime: {value} {unit} is out of range
- Invalid interval: {0}
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/974ed8d6fc22a7ac.
Report an issue: GitHub.