Changeset: b5f5ae1f7832 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b5f5ae1f7832
Modified Files:
        sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test
Branch: Jun2023
Log Message:

add tests for dayname() and monthname() on a timestamp column (besides a date 
column).
The server console generates errors:
#2023-05-17 19:21:40: client3: parse_date: ERROR: Syntax error in date.
#2023-05-17 19:21:40: client3: VARconvert: ERROR: 22018!conversion of string 
'%A' to type timestamp failed.
#2023-05-17 19:21:40: client3: SQLrun: INFO: Executing: select {fn dayname(ts)} 
from dtm

#2023-05-17 19:21:40: client3: parse_date: ERROR: Syntax error in date.
#2023-05-17 19:21:40: client3: VARconvert: ERROR: 22018!conversion of string 
'%B' to type timestamp failed.
#2023-05-17 19:21:40: client3: SQLrun: INFO: Executing: select {fn 
monthname(ts)} from dtm

This is because dayname() and monthname() are replaced in the parser into 
date_to_str() which only accepts a date
It would be better if we had functions const char * date_dayofweekname() and 
const char * date_monthname() in gdk_time.c similar to date_dayofweek() and 
date_month() but returning a const char * instead of bte.
That would also be faster than the current date_to_str(dt, format) format 
parser.


diffs (130 lines):

diff --git 
a/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test 
b/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test
--- a/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test
+++ b/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test
@@ -72,22 +72,42 @@ select { fn dayname(date'2022-11-11') }
 ----
 Friday
 
+query T rowsort
+select { fn dayname({ts '2022-11-11 23:45:56'}) }
+----
+Friday
+
 query I rowsort
 select { fn dayofmonth(date'2022-11-11') }
 ----
 11
 
 query I rowsort
+select { fn dayofmonth({ts '2022-11-11 23:45:56'}) }
+----
+11
+
+query I rowsort
 select { fn dayofweek(date'2022-11-11') }
 ----
 5
 
 query I rowsort
+select { fn dayofweek({ts '2022-11-11 23:45:56'}) }
+----
+5
+
+query I rowsort
 select { fn dayofyear(date'2022-01-31') }
 ----
 31
 
 query I rowsort
+select { fn dayofyear({ts '2022-11-11 23:45:56'}) }
+----
+315
+
+query I rowsort
 select { fn extract(day from date'2022-01-02') }
 ----
 2
@@ -192,11 +212,21 @@ select { fn month(date'2022-11-14') }
 ----
 11
 
+query I rowsort
+select { fn month({ts'2022-11-14 22:33:44'}) }
+----
+11
+
 query T rowsort
 select { fn monthname(date'2022-11-14') }
 ----
 November
 
+query T rowsort
+select { fn monthname({ts'2022-11-14 22:33:44'}) }
+----
+November
+
 query I rowsort
 select {fn now()} > timestamp'2022-01-02 15:45:59'
 ----
@@ -483,3 +513,61 @@ query I rowsort
 select { fn timestampdiff(SQL_TSI_YEAR, time'22:00:00', (select now + interval 
'1' year)) }
 ----
 1
+
+statement ok
+create table dtm (dt date, tm time, ts timestamp)
+
+statement ok
+insert into dtm values ('2023-05-17',' 12:34', '2023-05-17 12:34')
+
+statement ok
+insert into dtm values ('3023-06-17',' 12:34', '3023-06-17 12:34')
+
+statement ok
+insert into dtm values ('1023-07-17',' 12:34', '1023-07-17 12:34')
+
+statement ok
+insert into dtm
+
+statement ok
+insert into dtm values ('1923-12-17',' 12:34', '1923-12-17 12:34')
+
+query T rowsort
+select {fn dayname(dt)} from dtm
+----
+Monday
+NULL
+Thursday
+Tuesday
+Wednesday
+
+query T rowsort
+select {fn dayname(ts)} from dtm
+----
+Monday
+NULL
+Thursday
+Tuesday
+Wednesday
+
+query T rowsort
+select {fn monthname(dt)} from dtm
+----
+December
+July
+June
+May
+NULL
+
+query T rowsort
+select {fn monthname(ts)} from dtm
+----
+December
+July
+June
+May
+NULL
+
+statement ok
+drop table if exists dtm
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to