Skip to content

Commit c8c985d

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 c8c985d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

db/types.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(rows inserted=1)
2+
(rows inserted=1)
3+
(d="1970-01-01T000000.000 UTC")
4+
(d="1970-08-17T001501.000 UTC")
5+
(epoch=0)
6+
(epoch=19700101)

tests/datetime.test/t25.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
INSERT INTO t25 VALUES("19700101")
6+
SELECT d FROM t25
7+
SELECT CAST(d AS INT) AS epoch FROM t25
8+
DROP TABLE t25

0 commit comments

Comments
 (0)