Skip to content

Commit bc595ea

Browse files
committed
Allowing omitting the "T" separator from a datetime string
Our customers have issue using spark to create a dataframe on a datetime column, because spark interpolates the provided datetime string, but drops the "T" separator when filling the range. It seems that omitting the "T" character is fairly acceptable, and ISO 8601 does allow it to be omitted in a few cases. This is a very simple patch to allow it. Signed-off-by: Rivers Zhang <[email protected]>
1 parent c986f00 commit bc595ea

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

db/types.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7202,7 +7202,7 @@ static int _isISO8601(const char *str, int len)
72027202
} else if (str[i] < '0' || str[i] > '9')
72037203
return 1;
72047204
if (!isalnum(str[i]) && str[i] != '-' && str[i] != ':' &&
7205-
str[i] != '.') {
7205+
str[i] != '.' && str[i] != ' ') {
72067206
/* invalid character in datetime string */
72077207
return -1;
72087208
}
@@ -7262,7 +7262,7 @@ static int _isISO8601(const char *str, int len)
72627262
/* (month<1 || month>12)*/ \
72637263
\
72647264
/*get day*/ \
7265-
day = getInt(in, len, &offset, &ltoken, 1, 2, "-T", &skipped); \
7265+
day = getInt(in, len, &offset, &ltoken, 1, 2, "-T ", &skipped); \
72667266
if (!ltoken) \
72677267
return CONV_WRONG_MDAY; \
72687268
/*(day <1 || !is_valid_days(year, month, day))*/ \

tests/datetime.test/t25.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(rows inserted=1)
2+
(d="1970-01-01T000000.000 UTC")

tests/datetime.test/t25.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SET TIMEZONE UTC
2+
DROP TABLE IF EXISTS t25
3+
CREATE TABLE t25(d datetime)$$
4+
INSERT INTO t25 VALUES("1970-01-01 00:00:00 UTC")
5+
SELECT * FROM t25 WHERE d = "1970-01-01 00:00:00 UTC"
6+
DROP TABLE t25

0 commit comments

Comments
 (0)