{"record":{"id":"00b4934ec4560ecd","repo":"risingwavelabs/risingwave","slug":"date-time-field","errorCode":null,"errorMessage":"date/time field","messagePattern":"date/time field","errorType":"validation","errorClass":"ParserError","httpStatus":null,"severity":"error","filePath":"src/sqlparser/src/parser.rs","lineNumber":1195,"sourceCode":"            let value = parser.parse_expr()?;\n            Ok((key, value))\n        })?;\n        self.expect_token(&Token::RBrace)?;\n        Ok(Expr::Map { entries })\n    }\n\n    // This function parses date/time fields for interval qualifiers.\n    pub fn parse_date_time_field(&mut self) -> ModalResult<DateTimeField> {\n        dispatch! { peek(keyword);\n            Keyword::YEAR => keyword.value(DateTimeField::Year),\n            Keyword::MONTH => keyword.value(DateTimeField::Month),\n            Keyword::DAY => keyword.value(DateTimeField::Day),\n            Keyword::HOUR => keyword.value(DateTimeField::Hour),\n            Keyword::MINUTE => keyword.value(DateTimeField::Minute),\n            Keyword::SECOND => keyword.value(DateTimeField::Second),\n            _ => fail,\n        }\n        .expect(\"date/time field\")\n        .parse_next(self)\n    }\n\n    // This function parses date/time fields for the EXTRACT function-like operator. PostgreSQL\n    // allows arbitrary inputs including invalid ones.\n    //\n    // ```\n    //   select extract(day from null::date);\n    //   select extract(invalid from null::date);\n    //   select extract(\"invaLId\" from null::date);\n    //   select extract('invaLId' from null::date);\n    // ```\n    pub fn parse_date_time_field_in_extract(&mut self) -> ModalResult<String> {\n        let checkpoint = *self;\n        let token = self.next_token();\n        match token.token {\n            Token::Word(w) => Ok(w.value.to_uppercase()),\n            Token::SingleQuotedString(s) => Ok(s.to_uppercase()),","sourceCodeStart":1177,"sourceCodeEnd":1213,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/sqlparser/src/parser.rs#L1177-L1213","documentation":"Raised by `parse_date_time_field` when parsing an INTERVAL literal's unit field. The grammar here only accepts YEAR, MONTH, DAY, HOUR, MINUTE, SECOND (and the plural/quarter/week forms handled above the shown snippet); any other identifier after `INTERVAL` fails and `.expect(\"date/time field\")` yields the error. It means the interval unit keyword is invalid for this dialect.","triggerScenarios":"Parsing `INTERVAL <n> <unit>` where unit is not a recognized date/time field, e.g. `INTERVAL 1 FORTNIGHT`, `INTERVAL 5 DAYS` in a dialect that only accepts DAY, or a misspelled unit like `INTERVAL 1 MOTH`.","commonSituations":"Porting interval literals from other SQL engines with extra units (FORTNIGHT, DECADE); typos in interval units; programmatic SQL generation building interval strings from user input.","solutions":["Use a supported unit: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND (and the other recognized fields such as QUARTER/WEEK if listed above the snippet).","Rewrite unsupported units into supported ones, e.g. `INTERVAL '2 weeks'` -> `INTERVAL 14 DAY`.","Validate user-supplied interval units against the allowed set before interpolating into SQL."],"exampleFix":"// before\nSELECT now() + INTERVAL 1 FORTNIGHT;\n// after\nSELECT now() + INTERVAL 14 DAY;","handlingStrategy":"validation","validationCode":"const FIELDS = new Set(['YEAR','MONTH','DAY','HOUR','MINUTE','SECOND','QUARTER','WEEK']);\nfunction validIntervalField(u) { return FIELDS.has(u.toUpperCase()); }","typeGuard":"const isDateTimeField = (s) => typeof s === 'string' && ['YEAR','MONTH','DAY','HOUR','MINUTE','SECOND','QUARTER','WEEK'].includes(s.toUpperCase());","tryCatchPattern":null,"preventionTips":["Validate user-supplied interval units against the supported set before string interpolation.","Convert unsupported units (fortnight, decade) to supported ones at generation time.","Never build INTERVAL literals directly from free-form user input."],"tags":["sql","parser","interval","syntax"],"backgroundTag":"invalid-enum-value","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"}