Quanlong Huang has uploaded this change for review. ( http://gerrit.cloudera.org:8080/23371
Change subject: IMPALA-14383: Fix crash in casting timestamp string with timezone offsets to DATE ...................................................................... IMPALA-14383: Fix crash in casting timestamp string with timezone offsets to DATE Timestamp string can have a timezone offset at its end, e.g. "2025-08-31 06:23:24.9392129 +08:00" has "+08:00" as the timezone offset. When casting strings to DATE type, we try to find the default format by matching the separators, i.e. '-', ':', ' ', etc in SimpleDateFormatTokenizer::GetDefaultFormatContext(). The one that matches this example is DEFAULT_DATE_TIME_CTX[] which represents the default date/time context for "yyyy-MM-dd HH:mm:ss.SSSSSSSSS". The fractional part at the end can have length from 0 to 9, matching DEFAULT_DATE_TIME_CTX[0] to DEFAULT_DATE_TIME_CTX[9] respectively. When calculating which item in DEFAULT_DATE_TIME_CTX is the matched format, we use the index as str_len - 20 where 20 is the length of "yyyy-MM-dd HH:mm:ss.". This causes the index overflow if the string length is larger than 29. A wild pointer is returned from GetDefaultFormatContext(), leading crash in following codes. This patch fixes the issue by adding a check to make sure the string length is smaller than the max length of the default date time format, i.e. DEFAULT_DATE_TIME_FMT_LEN (29). Longer strings will use DateTimeFormatContext created lazily. Note that this just fixes the crash. Converting timestamp strings with timezone offset at the end to DATE type is not supported yet and will be followed up in IMPALA-14391. Tests - Added e2e tests on constant expressions. Also added a test table with such timestamp strings and added test on it. Change-Id: I36d73f4a71432588732b2284ac66552f75628a62 --- M be/src/runtime/datetime-simple-date-format-parser.cc M testdata/datasets/functional/functional_schema_template.sql M testdata/datasets/functional/schema_constraints.csv M testdata/workloads/functional-query/queries/QueryTest/date.test 4 files changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/71/23371/1 -- To view, visit http://gerrit.cloudera.org:8080/23371 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I36d73f4a71432588732b2284ac66552f75628a62 Gerrit-Change-Number: 23371 Gerrit-PatchSet: 1 Gerrit-Owner: Quanlong Huang <[email protected]>
