Skip to content

[SPARK-29494][SQL] Fix for ArrayOutofBoundsException while converting string to timestamp #26143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ object DateTimeUtils {
i += 1
}
} else {
if (b == ':' || b == ' ') {
if (i < segments.length && (b == ':' || b == ' ')) {
segments(i) = currentSegmentValue
currentSegmentValue = 0
i += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ class DateTimeUtilsSuite extends SparkFunSuite with Matchers {
}
}

test("trailing characters while converting string to timestamp") {
val s = UTF8String.fromString("2019-10-31T10:59:23Z:::")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You described 2 cases in the PR discription ':' and ' '. This test checks the first one only. Could you add at least one more check for ' '.

val time = DateTimeUtils.stringToTimestamp(s, defaultZoneId)
assert(time == None)
}

test("truncTimestamp") {
def testTrunc(
level: Int,
Expand Down