Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
}
}