github.com/matrixorigin/matrixone@v0.7.0/test/distributed/cases/function/func_string_reverse.test (about)

     1  #SELECT 
     2  SELECT REVERSE('abc');
     3  -- @separator:table
     4  select reverse('abc'),reverse('abcd');
     5  
     6  #NULL
     7  select reverse(NULL);
     8  
     9  
    10  #嵌套, 子查询
    11  #0.5暂不支持
    12  #CREATE TABLE t1(id INT);
    13  #INSERT INTO t1 VALUES (1),(2),(3),(4);
    14  #SELECT REVERSE(EXISTS(SELECT * FROM t1));
    15  #DROP TABLE t1;
    16  
    17  #WHERE
    18  create table t1 (a varchar(20));
    19  insert into t1 values ("empty"),(""),("hello");
    20  -- @separator:table
    21  select a,reverse(a) from t1 where reverse(a)="olleh";
    22  drop table t1;
    23  
    24  #字符集
    25  
    26  drop table if exists `T1`;
    27  drop table if exists `T2`;
    28  drop table if exists `T3`;
    29  drop table if exists `T4`;
    30  drop table if exists `T5`;
    31  drop table if exists `T6`;
    32  drop table if exists `T7`;
    33  drop table if exists `T8`;
    34  drop table if exists `T9`;
    35  CREATE TABLE `T1` (`C1` char(50), INDEX(`C1`));
    36  CREATE TABLE `T2` (`C1` char(50), INDEX(`C1`));
    37  CREATE TABLE `T3` (`C1` char(50), INDEX(`C1`));
    38  CREATE TABLE `T4` (`C1` char(50), INDEX(`C1`));
    39  CREATE TABLE `T5` (`C1` char(50), INDEX(`C1`));
    40  CREATE TABLE `T6` (`C1` char(50), INDEX(`C1`));
    41  CREATE TABLE `T7` (`C1` char(50), INDEX(`C1`));
    42  CREATE TABLE `T8` (`C1` char(50), INDEX(`C1`));
    43  CREATE TABLE `T9` (`C1` char(50), INDEX(`C1`));
    44  INSERT INTO `T1` VALUES ('アイウエオ');
    45  INSERT INTO `T2` VALUES ('あいうえお');
    46  INSERT INTO `T3` VALUES ('龔龖龗龞龡');
    47  INSERT INTO `T4` VALUES ('アイウエオ');
    48  INSERT INTO `T5` VALUES ('あいうえお');
    49  INSERT INTO `T6` VALUES ('龔龖龗龞龡');
    50  INSERT INTO `T7` VALUES ('アイウエオ');
    51  INSERT INTO `T8` VALUES ('あいうえお');
    52  INSERT INTO `T9` VALUES ('龔龖龗龞龡');
    53  SELECT REVERSE(`C1`) FROM `T1`;
    54  SELECT REVERSE(`C1`) FROM `T2`;
    55  SELECT REVERSE(`C1`) FROM `T3`;
    56  SELECT REVERSE(`C1`) FROM `T4`;
    57  SELECT REVERSE(`C1`) FROM `T5`;
    58  SELECT REVERSE(`C1`) FROM `T6`;
    59  SELECT REVERSE(`C1`) FROM `T7`;
    60  SELECT REVERSE(`C1`) FROM `T8`;
    61  SELECT REVERSE(`C1`) FROM `T9`;
    62  DROP TABLE `T1`;
    63  DROP TABLE `T2`;
    64  DROP TABLE `T3`;
    65  DROP TABLE `T4`;
    66  DROP TABLE `T5`;
    67  DROP TABLE `T6`;
    68  DROP TABLE `T7`;
    69  DROP TABLE `T8`;
    70  DROP TABLE `T9`;
    71  
    72  
    73  #中文
    74  SELECT REVERSE("你好");
    75  SELECT REVERSE("再 见");
    76  
    77  
    78  #HAVING & 算术运算, INSERT INTO
    79  drop table if exists t1;
    80  create table t1(a varchar(255));
    81  insert into t1 select (reverse("abc"));
    82  insert into t1 select (reverse("bcd"));
    83  insert into t1 select (reverse("def"));
    84  insert into t1 select (reverse("xyz"));
    85  insert into t1 select (reverse("1a1"));
    86  select a from t1 group by a having reverse(a)=reverse(a);
    87  drop table t1;
    88  
    89  #DISTINCT,ON CONDITION
    90  drop table if exists t1;
    91  drop table if exists t2;
    92  create table t1(a INT,  b varchar(255));
    93  create table t2(a INT,  b varchar(255));
    94  insert into t1 values(1, "abc"),(1, "bbb"),(3, "aaa"),(4, "2012");
    95  insert into t2 values(1, "abc"),(1, "aaa"),(3, "cba"),(4, "2012");
    96  SELECT distinct t1.a, t2.a FROM t1 JOIN t2 ON (reverse(t1.b) = reverse(t2.b));
    97  drop table t1;
    98  drop table t2;
    99  
   100  #EXTREME VALUE
   101  SELECT REVERSE("@($)@($#)_@(#");
   102  -- @separator:table
   103  SELECT REVERSE(space(500)+space(600));
   104  #DATA TYPES
   105  SELECT REVERSE(123124);
   106  SELECT REVERSE(123.124);
   107  SELECT REVERSE(0.3414);
   108  
   109  SELECT REVERSE("2023-04-24");
   110  SELECT REVERSE("10:03:23.021412");
   111  
   112  
   113