Changeset: 0b0301d4dc3f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0b0301d4dc3f
Added Files:
sql/test/datetime/Tests/str_to_timestamp.test
Modified Files:
monetdb5/modules/atoms/mtime.c
sql/test/datetime/Tests/All
Branch: mtime-bug
Log Message:
Fixes str_to_timestamp signature
diffs (91 lines):
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -1820,8 +1820,8 @@ static mel_func mtime_init_funcs[] = {
pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk_p1, false,
"", args(1,4,
batarg("",timestamp),arg("s",str),batarg("format",str),arg("tz_msec",lng))),
pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk_p2, false,
"", args(1,4,
batarg("",timestamp),batarg("s",str),arg("format",str),arg("tz_msec",lng))),
pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk, false,
"", args(1,6,
batarg("",timestamp),batarg("d",str),batarg("format",str),batarg("s1",oid),batarg("s2",oid),arg("tz_msec",lng))),
- pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk_p1, false,
"", args(1,5,
batarg("",timestamp),arg("s",str),batarg("format",str),batarg("s",oid),arg("tz_msec",lng))),
- pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk_p2, false,
"", args(1,5,
batarg("",timestamp),batarg("s",str),arg("format",str),batarg("s",oid),arg("tz_msec",lng))),
+ pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk_p1, false,
"", args(1,5,
batarg("",timestamp),arg("s",str),batarg("format",str),arg("tz_msec",lng),batarg("s",oid))),
+ pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk_p2, false,
"", args(1,5,
batarg("",timestamp),batarg("s",str),arg("format",str),arg("tz_msec",lng),batarg("s",oid))),
command("mtime", "timestamp_to_str", MTIMEtimestamp_to_str, false, "create a
string from the time, using the specified format (see man strftime)", args(1,3,
arg("",str),arg("d",timestamp),arg("format",str))),
pattern("batmtime", "timestamp_to_str", MTIMEtimestamp_to_str_bulk, false,
"", args(1,3, batarg("",str),batarg("d",timestamp),batarg("format",str))),
pattern("batmtime", "timestamp_to_str", MTIMEtimestamp_to_str_bulk_p1, false,
"", args(1,3, batarg("",str),arg("d",timestamp),batarg("format",str))),
diff --git a/sql/test/datetime/Tests/All b/sql/test/datetime/Tests/All
--- a/sql/test/datetime/Tests/All
+++ b/sql/test/datetime/Tests/All
@@ -1,2 +1,3 @@
str_to_date
str_to_time
+str_to_timestamp
diff --git a/sql/test/datetime/Tests/str_to_timestamp.test
b/sql/test/datetime/Tests/str_to_timestamp.test
new file mode 100644
--- /dev/null
+++ b/sql/test/datetime/Tests/str_to_timestamp.test
@@ -0,0 +1,65 @@
+statement ok
+create table isp (n int, s varchar(30), p varchar(30))
+
+statement ok
+insert into isp values
+ (1, '2021-01-01 00:00:12', '%Y-%m-%d %H:%M:%S'),
+ (2, '2022-01-01 00:01:23', '%Y-%d-%m %H:%M:%S'),
+ (3, '2023-01-01 00:12:34', '%F %T')
+
+query IT rowsort
+select n, str_to_timestamp(s,'%Y-%m-%d %H:%M:%S') from isp
+----
+1
+2021-01-01 00:00:12+01:00
+2
+2022-01-01 00:01:23+01:00
+3
+2023-01-01 00:12:34+01:00
+
+# the CASE clause assures that we use a bat version of str_to_timestamp
+# which accept oid as arguments for the case of CASE condition (see MAL)
+query IT rowsort
+select n,
+ case when n < 2 then
+ str_to_timestamp(s,'%Y-%m-%d %H:%M:%S')
+ else
+ str_to_timestamp(s,'%Y-%m-%d %H:%M:%S')
+ end
+from isp
+----
+1
+2021-01-01 00:00:12+01:00
+2
+2022-01-01 00:01:23+01:00
+3
+2023-01-01 00:12:34+01:00
+
+query IT rowsort
+select n, str_to_timestamp('2023-01-11 00:12:34', p) from isp
+----
+1
+2023-01-11 00:12:34+01:00
+2
+2023-11-01 00:12:34+01:00
+3
+2023-01-11 00:12:34+01:00
+
+# the CASE clause assures that we use a bat version of str_to_timestamp
+# which accept oid as arguments for the case of CASE condition (see MAL)
+query IT rowsort
+select n,
+ case when n < 2 then
+ str_to_timestamp('2023-01-11 00:12:34', p)
+ else
+ str_to_timestamp('2023-01-11 00:12:34', p)
+ end
+from isp
+----
+1
+2023-01-11 00:12:34+01:00
+2
+2023-11-01 00:12:34+01:00
+3
+2023-01-11 00:12:34+01:00
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]