#93 : failures on parsing timestamp with timezone#95
#93 : failures on parsing timestamp with timezone#95MatloaItumeleng wants to merge 1 commit intomasterfrom
Conversation
|
JaCoCo code coverage report - scala 2.12.20
|
There was a problem hiding this comment.
Pull request overview
This PR fixes timestamp parsing for patterns that include quoted literals (e.g., ISO-8601 yyyy-MM-dd'T'HH:mm:ss.SSSXXX) by correcting how second-fraction section indexes are mapped from the pattern to the input value string, and adds regression tests for the reported failure.
Changes:
- Update
DateTimePatternsecond-fraction scanning to computepatternWithoutSecondFractionsfrom pattern indexes while adjusting extracted/removal section indexes for value strings with quoted literals. - Add a regression test covering parsing of a timezone + milliseconds timestamp with a quoted literal (
'T') in the pattern. - Add a
DateTimePatternunit test validating fraction detection/stripping for the same quoted-literal + timezone pattern.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main/scala/za/co/absa/standardization/time/DateTimePattern.scala | Adjusts second-fraction section index handling for patterns containing quoted literals; recomputes patternWithoutSecondFractions from pattern-based sections. |
| src/test/scala/za/co/absa/standardization/types/parsers/DateTimeParserSuite.scala | Adds regression coverage for parsing ISO-like timestamps with timezone + milliseconds and quoted literals in the pattern. |
| src/test/scala/za/co/absa/standardization/time/DateTimePatternSuite.scala | Adds a unit test for second-fraction detection/stripping in quoted-literal + timezone patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def adjust(sectionOpt: Option[Section]): Option[Section] = { | ||
| sectionOpt.map { s => | ||
| val quotesBefore = pat.substring(0, s.start).count(_ == '\'') | ||
| s.copy(start = s.start - quotesBefore) | ||
| } |
| test("DateParser class actual pattern with quoted literal and timezone and milliseconds") { | ||
| val parser = DateTimeParser("yyyy-MM-dd'T'HH:mm:ss.SSSXXX") | ||
| val str = "2025-07-18T16:07:51.569+02:00" | ||
|
|
||
| val resultDate: Date = parser.parseDate(str) | ||
| val expectedDate: Date = Date.valueOf("2025-07-18") | ||
| assert(resultDate == expectedDate) | ||
|
|
||
| val resultTimestamp: Timestamp = parser.parseTimestamp(str) | ||
| val expectedTimestamp: Timestamp = Timestamp.valueOf("2025-07-18 14:07:51.569") | ||
| assert(resultTimestamp == expectedTimestamp) |
ABLL526
left a comment
There was a problem hiding this comment.
LGTM, although the Co-Pilot made some valid suggestions that need addressing IMO.
salamonpavel
left a comment
There was a problem hiding this comment.
LGTM (read the code), do address Copilot's suggestions otherwise ok.
Release notes:
closes #93