github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/mo_log_date.sql (about)

     1  -- @suite
     2  -- @case
     3  -- @desc:test for builtin function mo_log_date()
     4  -- @label:bvt
     5  
     6  -- date part like %Y/%m/%d
     7  select mo_log_date('2021/01/01');
     8  select mo_log_date('1997/01/13');
     9  select mo_log_date('1969/01/01');
    10  select mo_log_date('1988/1/3');
    11  select mo_log_date('1970/01/3');
    12  select mo_log_date('1970/9/29');
    13  select mo_log_date('20/12/12');
    14  select mo_log_date('9/10/13');
    15  select mo_log_date('00/12/13');
    16  select mo_log_date('1/02/3');
    17  select mo_log_date(null);
    18  
    19  -- abnormal test: the year/month/day exceeds the normal boundary value
    20  select mo_log_date('1000/12/89');
    21  select mo_log_date('2023/13/19');
    22  select mo_log_date('12345/19/01');
    23  
    24  -- abnormal test: incorrect date format
    25  select mo_log_date('2020-01-01');
    26  select mo_log_date('1997-01-13');
    27  select mo_log_date('1000/02/(*');
    28  select mo_log_date('1997-&*-10');
    29  select mo_log_date('&&()-01-13');
    30  select mo_log_date('2022-12-{}');
    31  
    32  -- select between and
    33  select mo_log_date('2021/01/01') between '2021-01-01' and '2021-01-02' as val;
    34  select mo_log_date('1998/01/01') between '2021-01-01' and '2021-01-02' as val;
    35  select mo_log_date('1999/01/13') between '1970-01-01' and '2020-12-13' as val;
    36  select mo_log_date('2023/1/13') between '2023-01-13' and '2023-12-13' as val;
    37  select mo_log_date('2023/11/9') between '2023-1-9' and '2025-12-19' as val;
    38  
    39  -- > and <
    40  select mo_log_date('2023/01/03') > '2023-01-01' as val;
    41  select mo_log_date('1997/12/12') < '2023-12-12' as val;
    42  select mo_log_date('1995/12/30') > '1996-12-30' as val;
    43  select mo_log_date('2001/05/06') < '1997-07-03' as val;
    44  select mo_log_date('2020/01/06') > '2020-01-05' and mo_log_date('2020/01/06') < '2021-01-05';
    45  
    46  -- abnormal test
    47  select mo_log_date('2021-01-13') between '2020-01-13' and '2022-11-12';
    48  select mo_log_date('1997-01-13') between '1970-01-01' and '2023-04-24';
    49  
    50  -- mixed string
    51  select mo_log_date('数据库Database/table/2022/03/04/^&(*)(');
    52  select mo_log_date('hienrvkew/&*?/1970/01/01/uf893I');
    53  select mo_log_date('gyekucwheu3p2u4oi3k2if3u9i0ikvoi43kvk43io5juti4o3m48651/2023/2/28');
    54  select mo_log_date('yufiehw4&*(*)()_/1997/12/9/78weufiwhruewoijvriejbvrewkbe');
    55  select mo_log_date('dhiuwnjdksnfv/2023/2025/2029/04/05/hiuewhrijvewoke&**');
    56  select mo_log_date('dhiuwnjdksnfv/2023/04/05/09/hiuewhrijvewoke&**');
    57  select mo_log_date('abc/def/github/com');
    58  select mo_log_date('cuankjvar3242/ewhiuhj32i4jl3f/com/72989432');
    59  
    60  select mo_log_date('数据库Database/table/2022/chuiwne/03/04/6^&(*)(');
    61  select mo_log_date('hvjwejkv/1970/3823/djkvmfeve/12/24/vckjwrvew');
    62  
    63  -- char and varchar in the table
    64  drop table if exists date01;
    65  create table date01(col1 char(10),col2 varchar(100));
    66  insert into date01 values('1990/1/02','数据库Database/table/2022/03/04/^&(*)(');
    67  insert into date01 values('2020/11/6','gyekucwheu3p2u4oi3k2if3u9i0ikvoi43kvk43io5juti4o3m48651/2023/2/28');
    68  insert into date01 values(NULL,'yufiehw4&*(*)()_/1997/12/9/78weufiwhruewoijvriejbvrewkbe');
    69  insert into date01 values('2023/04/24','abc/def/github/com');
    70  select * from date01;
    71  
    72  select mo_log_date(col1) from date01;
    73  select mo_log_date(col2) from date01;
    74  
    75  select date(mo_log_date(col1)) as date1,date(mo_log_date(col2)) as date2 from date01;
    76  select date_add(mo_log_date(col1),interval 45 day) as date1 from date01;
    77  select date_add(mo_log_date(col2), interval 30 day) as date2 from date01;
    78  select date_format(mo_log_date(col1), '%W %M %Y') from date01;
    79  select date_format(mo_log_date(col2), '%D %y %a %d %m %b %j') from date01;
    80  select date_sub(mo_log_date(col1), interval 2 year) as date1, date_sub(mo_log_date(col2), interval 2 month) as date2 from date01;
    81  select datediff(mo_log_date(col1),mo_log_date(col2)) from date01;
    82  select day(mo_log_date(col1)),day(mo_log_date(col2)) from date01;
    83  select dayofyear(mo_log_date(col1)),dayofyear(mo_log_date(col2)) from date01;
    84  select extract(year from mo_log_date(col1)) as year1 from date01;
    85  select extract(year from mo_log_date(col2)) as year2 from date01;
    86  select extract(month from mo_log_date(col1)) as month from date01;
    87  select date_format(mo_log_date(col1), '%X %V') from date01;
    88  select date_format(mo_log_date(col2), '%X %V') from date01;
    89  select month(mo_log_date(col1)),month(mo_log_date(col2)) from date01;
    90  select weekday(mo_log_date(col1)),weekday(mo_log_date(col2)) from date01;
    91  select year(mo_log_date(col1)),year(mo_log_date(col2)) from date01;
    92  drop table date01;
    93  
    94  -- tinytext/mediumtext/longtext in the table
    95  drop table if exists text01;
    96  create table text01(col1 tinytext not null, col2 mediumtext default null, col3 longtext);
    97  insert into text01 values('1878/02/23','euiwq32/2019/8d29f/03/04','tdyuh3n1iuhfiu4h2fiu432gig432jfcurenvu4hiu32hmvcke4mvn439809328093284092432/1990/38209483298432042/03/04/4328932094820941032fkiwjvklwegvre');
    98  insert into text01 values('1989/1/25',null,'789798888888888444451<>>?<></2020/12/13/14/89954454]\[\[]0');
    99  insert into text01 values('23/01/15','deuwiqjiq/20/12/12','897e7fwqefi38928749208492*(&^(&**)(*/199/11/25/ewpqorpewoeq');
   100  select * from text01;
   101  
   102  select mo_log_date(col1) from text01;
   103  select mo_log_date(col2) from text01;
   104  select mo_log_date(col3) from text01;
   105  
   106  -- nested with date function
   107  select date(mo_log_date(col1)) as date1,date(mo_log_date(col2)) as date2, date(mo_log_date(col3)) as date3 from text01;
   108  select date_add(mo_log_date(col1),interval 45 day) as date1 from text01;
   109  select date_add(mo_log_date(col2), interval 30 day) as date2 from text01;
   110  select date_add(mo_log_date(col3), interval 30 day) as date3 from text01;
   111  select date_format(mo_log_date(col1), '%W %M %Y') from text01;
   112  select date_format(mo_log_date(col2), '%D %y %a %d %m %b %j') from text01;
   113  select date_format(mo_log_date(col3), '%D %y %a %d %m %b %j') from text01;
   114  select date_sub(mo_log_date(col1), interval 2 year) as date1, date_sub(mo_log_date(col2), interval 2 month) as date2,date_sub(mo_log_date(col3), interval 2 day) as date3 from text01;
   115  select datediff(mo_log_date(col1),mo_log_date(col2)) from text01;
   116  select day(mo_log_date(col1)),day(mo_log_date(col2)),day(mo_log_date(col3)) from text01;
   117  select dayofyear(mo_log_date(col1)),dayofyear(mo_log_date(col2)),dayofyear(mo_log_date(col3)) from text01;
   118  select extract(year from mo_log_date(col1)) as year1 from text01;
   119  select extract(year from mo_log_date(col2)) as year2 from text01;
   120  select extract(month from mo_log_date(col1)) as month from text01;
   121  select extract(year from mo_log_date(col2)) as year from text01;
   122  select date_format(mo_log_date(col1), '%X %V') from text01;
   123  select date_format(mo_log_date(col2), '%X %V') from text01;
   124  select date_format(mo_log_date(col3), '%X %V') from text01;
   125  select month(mo_log_date(col1)),month(mo_log_date(col2)),month(mo_log_date(col3)) from text01;
   126  select weekday(mo_log_date(col1)),weekday(mo_log_date(col2)),weekday(mo_log_date(col3)) from text01;
   127  select year(mo_log_date(col1)),year(mo_log_date(col2)),year(mo_log_date(col3)) from text01;
   128  drop table text01;
   129  
   130  -- nested with date funciton
   131  select date(mo_log_date('hienrvkew/&*?/1970/01/01/uf893I'));
   132  select date_add(mo_log_date('数据库/2021/01/01/guanli系统'),interval 45 day);
   133  select date_format(mo_log_date('dhiuwnjdksnfv/2023/2025/2029/04/05/hiuewhrijvewoke&**'), '%W %M %Y');
   134  select date_format(mo_log_date('数据库Database/table/2022/03/04/^&(*)('), '%D %y %a %d %m %b %j');
   135  select date_sub(mo_log_date('2021/01/01'), interval 2 year);
   136  select datediff(mo_log_date('2023/04/25'),mo_log_date('2024/04/25'));
   137  select day(mo_log_date('新版本下个月发布/2045/1998/12/29/78/&**('));
   138  select dayofyear(mo_log_date('1996/12/29'));
   139  select extract(year from mo_log_date('2029/01/14')) as year;
   140  select extract(month from mo_log_date('2029/01/14')) as month;
   141  select date_format(mo_log_date('2029/01/14'), '%X %V');
   142  select month(mo_log_date('1990/1/25'));
   143  select weekday(mo_log_date('1258/2026/4/27/88ijmm'));
   144  select year(mo_log_date('1212/01/03'));
   145  
   146  -- date function nested with the columns of the table
   147  drop table if exists date02;
   148  create table date02(col1 text);
   149  insert into date02 values('sfiuenhfwu8793u2r43r/2020/02/02');
   150  select mo_log_date(col1) from date02;
   151  drop table date02;