Changeset: fee6d1c5f72a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fee6d1c5f72a
Branch: default
Log Message:

Merges Aug2024 branch


diffs (truncated from 441 to 300 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
@@ -608,8 +608,8 @@ NAME##_bulk_p1(Client cntxt, MalBlkPtr m
        bool nils = false;                                                      
                                                \
        bat *ret = getArgReference_bat(stk, pci, 0),                            
                \
                *bid2 = getArgReference_bat(stk, pci, 2),                       
                        \
-               *sid2 = pci->argc == 5 ? getArgReference_bat(stk, pci, 3) : 
NULL; \
-       lng *extra = getArgReference_lng(stk, pci, pci->argc-1);                
                                \
+               *sid2 = pci->argc == 5 ? getArgReference_bat(stk, pci, 4) : 
NULL; \
+       lng *extra = getArgReference_lng(stk, pci, 3);                          
                \
        const INTYPE1 src1 = *(INTYPE1*)getArgReference(stk, pci, 1);           
\
        BATiter b2i;                                                            
                                                \
        DEC_SRC2(INTYPE2, 2);                                                   
                                        \
@@ -685,8 +685,8 @@ NAME##_bulk_p2(Client cntxt, MalBlkPtr m
        bool nils = false;                                                      
                                                \
        bat *ret = getArgReference_bat(stk, pci, 0),                            
                \
                *bid1 = getArgReference_bat(stk, pci, 1),                       
                        \
-               *sid1 = pci->argc == 5 ? getArgReference_bat(stk, pci, 3) : 
NULL; \
-       lng *extra = getArgReference_lng(stk, pci, pci->argc-1);                
                                \
+               *sid1 = pci->argc == 5 ? getArgReference_bat(stk, pci, 4) : 
NULL; \
+       lng *extra = getArgReference_lng(stk, pci, 3);                          
                \
        BATiter b1i;                                                            
                                                \
        DEC_SRC1(INTYPE1, 1);                                                   
                                        \
        const INTYPE2 src2 = *(INTYPE2*)getArgReference(stk, pci, 2);           
\
@@ -1785,8 +1785,8 @@ static mel_func mtime_init_funcs[] = {
  pattern("batmtime", "str_to_date", MTIMEstr_to_date_bulk_p1, false, "", 
args(1,4, 
batarg("",date),arg("s",str),batarg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "str_to_date", MTIMEstr_to_date_bulk_p2, false, "", 
args(1,4, 
batarg("",date),batarg("s",str),arg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "str_to_date", MTIMEstr_to_date_bulk, false, "", 
args(1,6, 
batarg("",date),batarg("s",str),batarg("format",str),batarg("s1",oid),batarg("s2",oid),arg("tz_msec",lng))),
- pattern("batmtime", "str_to_date", MTIMEstr_to_date_bulk_p1, false, "", 
args(1,5, 
batarg("",date),arg("s",str),batarg("format",str),batarg("s",oid),arg("tz_msec",lng))),
- pattern("batmtime", "str_to_date", MTIMEstr_to_date_bulk_p2, false, "", 
args(1,5, 
batarg("",date),batarg("s",str),arg("format",str),batarg("s",oid),arg("tz_msec",lng))),
+ pattern("batmtime", "str_to_date", MTIMEstr_to_date_bulk_p1, false, "", 
args(1,5, 
batarg("",date),arg("s",str),batarg("format",str),arg("tz_msec",lng),batarg("s",oid))),
+ pattern("batmtime", "str_to_date", MTIMEstr_to_date_bulk_p2, false, "", 
args(1,5, 
batarg("",date),batarg("s",str),arg("format",str),arg("tz_msec",lng),batarg("s",oid))),
  command("mtime", "date_to_str", MTIMEdate_to_str, false, "create a string 
from the date, using the specified format (see man strftime)", args(1,3, 
arg("",str),arg("d",date),arg("format",str))),
  pattern("batmtime", "date_to_str", MTIMEdate_to_str_bulk, false, "", 
args(1,3, batarg("",str),batarg("d",date),batarg("format",str))),
  pattern("batmtime", "date_to_str", MTIMEdate_to_str_bulk_p1, false, "", 
args(1,3, batarg("",str),arg("d",date),batarg("format",str))),
@@ -1799,8 +1799,8 @@ static mel_func mtime_init_funcs[] = {
  pattern("batmtime", "str_to_time", MTIMEstr_to_time_bulk_p1, false, "", 
args(1,4, 
batarg("",daytime),arg("s",str),batarg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "str_to_time", MTIMEstr_to_time_bulk_p2, false, "", 
args(1,4, 
batarg("",daytime),batarg("s",str),arg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "str_to_time", MTIMEstr_to_time_bulk, false, "", 
args(1,6, 
batarg("",daytime),batarg("s",str),batarg("format",str),batarg("s1",oid),batarg("s2",oid),arg("tz_msec",lng))),
- pattern("batmtime", "str_to_time", MTIMEstr_to_time_bulk_p1, false, "", 
args(1,5, 
batarg("",daytime),arg("s",str),batarg("format",str),batarg("s",oid),arg("tz_msec",lng))),
- pattern("batmtime", "str_to_time", MTIMEstr_to_time_bulk_p2, false, "", 
args(1,5, 
batarg("",daytime),batarg("s",str),arg("format",str),batarg("s",oid),arg("tz_msec",lng))),
+ pattern("batmtime", "str_to_time", MTIMEstr_to_time_bulk_p1, false, "", 
args(1,5, 
batarg("",daytime),arg("s",str),batarg("format",str),arg("tz_msec",lng),batarg("s",oid))),
+ pattern("batmtime", "str_to_time", MTIMEstr_to_time_bulk_p2, false, "", 
args(1,5, 
batarg("",daytime),batarg("s",str),arg("format",str),arg("tz_msec",lng),batarg("s",oid))),
  command("mtime", "time_to_str", MTIMEtime_to_str, false, "create a string 
from the time, using the specified format (see man strftime)", args(1,3, 
arg("",str),arg("d",daytime),arg("format",str))),
  pattern("batmtime", "time_to_str", MTIMEtime_to_str_bulk, false, "", 
args(1,3, batarg("",str),batarg("d",daytime),batarg("format",str))),
  pattern("batmtime", "time_to_str", MTIMEtime_to_str_bulk_p1, false, "", 
args(1,3, batarg("",str),arg("d",daytime),batarg("format",str))),
@@ -1813,15 +1813,15 @@ static mel_func mtime_init_funcs[] = {
  pattern("batmtime", "timetz_to_str", MTIMEtimetz_to_str_bulk_p1, false, "", 
args(1,4, 
batarg("",str),arg("d",daytime),batarg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "timetz_to_str", MTIMEtimetz_to_str_bulk_p2, false, "", 
args(1,4, 
batarg("",str),batarg("d",daytime),arg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "timetz_to_str", MTIMEtimetz_to_str_bulk, false, "", 
args(1,6, 
batarg("",str),batarg("d",daytime),batarg("format",str),batarg("s1",oid),batarg("s2",oid),arg("tz_msec",lng))),
- pattern("batmtime", "timetz_to_str", MTIMEtimetz_to_str_bulk_p1, false, "", 
args(1,5, 
batarg("",str),arg("d",daytime),batarg("format",str),batarg("s",oid),arg("tz_msec",lng))),
- pattern("batmtime", "timetz_to_str", MTIMEtimetz_to_str_bulk_p2, false, "", 
args(1,5, 
batarg("",str),batarg("d",daytime),arg("format",str),batarg("s",oid),arg("tz_msec",lng))),
+ pattern("batmtime", "timetz_to_str", MTIMEtimetz_to_str_bulk_p1, false, "", 
args(1,5, 
batarg("",str),arg("d",daytime),batarg("format",str),arg("tz_msec",lng),batarg("s",oid))),
+ pattern("batmtime", "timetz_to_str", MTIMEtimetz_to_str_bulk_p2, false, "", 
args(1,5, 
batarg("",str),batarg("d",daytime),arg("format",str),arg("tz_msec",lng),batarg("s",oid))),
  command("mtime", "str_to_timestamp", MTIMEstr_to_timestamp, false, "create a 
timestamp from the string, using the specified format (see man strptime)", 
args(1,4, arg("",timestamp),arg("s",str),arg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "str_to_timestamp", MTIMEstr_to_timestamp_bulk, false, 
"", args(1,4, 
batarg("",timestamp),batarg("d",str),batarg("format",str),arg("tz_msec",lng))),
  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))),
@@ -1834,8 +1834,8 @@ static mel_func mtime_init_funcs[] = {
  pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p1, 
false, "", args(1,4, 
batarg("",str),arg("d",timestamp),batarg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p2, 
false, "", args(1,4, 
batarg("",str),batarg("d",timestamp),arg("format",str),arg("tz_msec",lng))),
  pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk, 
false, "", args(1,6, 
batarg("",str),batarg("d",timestamp),batarg("format",str),batarg("s1",oid),batarg("s2",oid),arg("tz_msec",lng))),
- pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p1, 
false, "", args(1,5, 
batarg("",str),arg("d",timestamp),batarg("format",str),batarg("s",oid),arg("tz_msec",lng))),
- pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p2, 
false, "", args(1,5, 
batarg("",str),batarg("d",timestamp),arg("format",str),batarg("s",oid),arg("tz_msec",lng))),
+ pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p1, 
false, "", args(1,5, 
batarg("",str),arg("d",timestamp),batarg("format",str),arg("tz_msec",lng),batarg("s",oid))),
+ pattern("batmtime", "timestamptz_to_str", MTIMEtimestamptz_to_str_bulk_p2, 
false, "", args(1,5, 
batarg("",str),batarg("d",timestamp),arg("format",str),arg("tz_msec",lng),batarg("s",oid))),
  command("mtime", "current_timestamp", MTIMEcurrent_timestamp, false, "", 
args(1,1, arg("",timestamp))),
  command("mtime", "current_date", MTIMEcurrent_date, false, "", args(1,1, 
arg("",date))),
  command("mtime", "current_time", MTIMEcurrent_time, false, "", args(1,1, 
arg("",daytime))),
diff --git a/sql/test/datetime/Tests/All b/sql/test/datetime/Tests/All
new file mode 100644
--- /dev/null
+++ b/sql/test/datetime/Tests/All
@@ -0,0 +1,5 @@
+str_to_date
+str_to_time
+str_to_timestamp
+time_to_str
+timestamp_to_str
diff --git a/sql/test/datetime/Tests/str_to_date.test 
b/sql/test/datetime/Tests/str_to_date.test
new file mode 100644
--- /dev/null
+++ b/sql/test/datetime/Tests/str_to_date.test
@@ -0,0 +1,66 @@
+statement ok
+create table idt (n int, d varchar(10), p varchar(10));
+
+statement ok
+insert into idt values 
+    (1, '2019-01-11', '%Y-%m-%d'),
+    (2, '2020-01-11', '%Y-%d-%m'),
+    (3, '2021-01-11', '%F')
+
+query IT rowsort
+select n, str_to_date(d, '%Y-%m-%d') from idt
+----
+1
+2019-01-11
+2
+2020-01-11
+3
+2021-01-11
+
+# the CASE clause assures that we use a bat version of str_to_date which
+# accept oid as arguments for the case of CASE condition (see the MAL)
+query IT rowsort
+select n, 
+    case when n < 2 then 
+        str_to_date(d,'%Y-%m-%d')
+    else 
+        str_to_date(d,'%Y-%m-%d') 
+    end
+from idt
+----
+1
+2019-01-11
+2
+2020-01-11
+3
+2021-01-11
+
+
+query IT rowsort
+select n, str_to_date('1999-01-12', p) from idt
+----
+1
+1999-01-12
+2
+1999-12-01
+3
+1999-01-12
+
+# the CASE clause assures that we use a bat version of str_to_date which
+# accept oid as arguments for the case of CASE condition (see the MAL)
+query IT rowsort
+select n, 
+    case when n < 2 then 
+        str_to_date('1999-01-12', p)
+    else 
+        str_to_date('1999-01-12', p) 
+    end
+from idt
+----
+1
+1999-01-12
+2
+1999-12-01
+3
+1999-01-12
+
diff --git a/sql/test/datetime/Tests/str_to_time.test 
b/sql/test/datetime/Tests/str_to_time.test
new file mode 100644
--- /dev/null
+++ b/sql/test/datetime/Tests/str_to_time.test
@@ -0,0 +1,65 @@
+statement ok
+create table itt (n int, t varchar(10), p varchar(10))
+
+statement ok
+insert into itt values 
+    (1, '00:01:02', '%H:%M:%S'),
+    (2, '00:10:02', '%H:%S:%M'),
+    (3, '00:20:02', '%T')
+
+query IT rowsort
+select n, str_to_time(t,'%H:%M:%S') from itt
+----
+1
+00:01:02+01:00
+2
+00:10:02+01:00
+3
+00:20:02+01:00
+
+# the CASE clause assures that we use a bat version of str_to_time which
+# accept oid as arguments for the case of CASE condition (see the MAL)
+query IT rowsort
+select n, 
+    case when n < 2 then 
+        str_to_time(t,'%H:%M:%S')
+    else 
+        str_to_time(t,'%H:%M:%S') 
+    end
+from itt
+----
+1
+00:01:02+01:00
+2
+00:10:02+01:00
+3
+00:20:02+01:00
+
+query IT rowsort
+select n, str_to_time('00:12:34', p) from itt
+----
+1
+00:12:34+01:00
+2
+00:34:12+01:00
+3
+00:12:34+01:00
+
+# the CASE clause assures that we use a bat version of str_to_time which
+# accept oid as arguments for the case of CASE condition (see the MAL)
+query IT rowsort
+select n,
+    case when n < 2 then
+        str_to_time('00:12:34',p)
+    else
+        str_to_time('00:12:34',p)
+    end
+from itt
+----
+1
+00:12:34+01:00
+2
+00:34:12+01:00
+3
+00:12:34+01:00
+
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
+
diff --git a/sql/test/datetime/Tests/time_to_str.test 
b/sql/test/datetime/Tests/time_to_str.test
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to