Skip to content

Commit

Permalink
Fix INVALID_DATETIME_PATTERN
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGekk committed Sep 10, 2024
1 parent 5f2d839 commit a1b3be5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,11 @@
"message" : [
"Too many letters in datetime pattern: <pattern>. Please reduce pattern length."
]
},
"SECONDS_FRACTION" : {
"message" : [
"Cannot detect a seconds fraction pattern of variable length. Please make sure the pattern contains 'S', and does not contain illegal characters."
]
}
},
"sqlState" : "22007"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private object DateTimeFormatterHelper {
rest = suffix
case _ =>
throw new SparkIllegalArgumentException(
errorClass = "INVALID_DATETIME_PATTERN",
errorClass = "INVALID_DATETIME_PATTERN.SECONDS_FRACTION",
messageParameters = Map("pattern" -> pattern))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,14 @@ class DateTimeFormatterHelperSuite extends SparkFunSuite {
assert(convertIncompatiblePattern("yyyy-MM-dd'e'HH:mm:ss") === "uuuu-MM-dd'e'HH:mm:ss")
assert(convertIncompatiblePattern("yyyy-MM-dd'T'") === "uuuu-MM-dd'T'")
}

test("SPARK-49583: invalid var length second fraction") {
val pattern = "\nSSSS\r"
checkError(
exception = intercept[SparkIllegalArgumentException] {
createBuilderWithVarLengthSecondFraction(pattern)
},
errorClass = "INVALID_DATETIME_PATTERN.SECONDS_FRACTION",
parameters = Map("pattern" -> pattern))
}
}

0 comments on commit a1b3be5

Please sign in to comment.