Skip to content

Commit

Permalink
GEOMESA-3297 Fix parsing of date splits
Browse files Browse the repository at this point in the history
  • Loading branch information
elahrvivaz committed Oct 6, 2023
1 parent b5eea5d commit 9645271
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -151,7 +151,7 @@ private class SplitPatternParser extends BasicParser {

private def year: Rule0 = rule { nTimes(4, "0" - "9") }

private def month: Rule0 = rule { ("0" - "1") ~ ("1" - "9") }
private def month: Rule0 = rule { ("0" ~ ("1" - "9")) | ("1" ~ ("0" - "2")) }

private def day: Rule0 = rule { ("0" - "3") ~ ("0" - "9") }
private def day: Rule0 = rule { (("0" - "2") ~ ("0" - "9")) | ("3" ~ ("0" - "1")) }
}
Expand Up @@ -111,6 +111,21 @@ class DefaultSplitterTest extends Specification {
splits.toSeq must containAllOf(dates)
}

"produce correct string tiered date splits for all dates" in {
foreach(Seq("2023-01-01", "2023-10-04", "2023-11-11", "2023-12-31")) { date =>
val opts =
"attr.myString.pattern:[A][B][C],attr.myString.pattern2:[B-Z]," +
s"attr.myString.date-range:2023-09-15/$date/4"
splitter.getSplits(sft, attrString, opts) must not(throwAn[Exception])
}
foreach(Seq("2023-01-32", "2023-13-04", "2023-00-11", "2023-12-00")) { date =>
val opts =
"attr.myString.pattern:[A][B][C],attr.myString.pattern2:[B-Z]," +
s"attr.myString.date-range:2023-09-15/$date/4"
splitter.getSplits(sft, attrString, opts) must throwAn[Exception]
}
}

"produce correct int splits" in {
val opts = "attr.myInt.pattern:[0-9]"
val splits = splitter.getSplits(sft, attrInt, opts)
Expand Down

0 comments on commit 9645271

Please sign in to comment.