github.com/matrixorigin/matrixone@v0.7.0/test/distributed/cases/operator/is_operator.result (about)

     1  drop table if exists tbl_int;
     2  CREATE TABLE tbl_int (col1 INT);
     3  INSERT INTO tbl_int VALUES (1), (2), (3), (4), (5), (6), (7), (8), (NULL), (NULL);
     4  SELECT * FROM tbl_int WHERE col1 IS NULL;
     5  col1
     6  null
     7  null
     8  SELECT * FROM tbl_int WHERE col1 IS NOT NULL;
     9  col1
    10  1
    11  2
    12  3
    13  4
    14  5
    15  6
    16  7
    17  8
    18  drop table if exists tbl_int;
    19  drop table if exists tbl_double;
    20  CREATE TABLE tbl_double (col1 DOUBLE);
    21  INSERT INTO tbl_double VALUES (-1.1), (0.0), (1.1), (2.2), (3.3), (4.4), (5.5), (6.6), (NULL), (NULL);
    22  SELECT * FROM tbl_double WHERE col1 IS NULL;
    23  col1
    24  null
    25  null
    26  SELECT * FROM tbl_double WHERE col1 IS NOT NULL;
    27  col1
    28  -1.1
    29  0.0
    30  1.1
    31  2.2
    32  3.3
    33  4.4
    34  5.5
    35  6.6
    36  drop table if exists tbl_double;
    37  drop table if exists tbl_datetime;
    38  CREATE TABLE tbl_datetime (col1 DATETIME(6));
    39  INSERT INTO tbl_datetime VALUES
    40  ("1000-01-01 00:00:01"), ("9999-12-31 23:59:59.999998"),
    41  ("2017-01-01 00:00:00"), ("2017-01-01 00:00:00.000001"),
    42  ("2017-02-01 00:00:00"), ("2018-01-01 00:00:00.999999"),
    43  ("2018-01-01 00:00:01"), ("3019-01-01 10:10:10.101010"), (NULL), (NULL);
    44  SELECT * FROM tbl_datetime WHERE col1 IS NULL;
    45  col1
    46  null
    47  null
    48  SELECT * FROM tbl_datetime WHERE col1 IS NOT NULL;
    49  col1
    50  1000-01-01 00:00:01
    51  9999-12-31 23:59:59.999998000
    52  2017-01-01 00:00:00
    53  2017-01-01 00:00:00.000001000
    54  2017-02-01 00:00:00
    55  2018-01-01 00:00:00.999999000
    56  2018-01-01 00:00:01
    57  3019-01-01 10:10:10.101010000
    58  drop table if exists tbl_datetime;
    59  drop table if exists tbl_decimal;
    60  CREATE TABLE tbl_decimal (col1 DECIMAL(65, 30));
    61  SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. For decimal(M), M must between 0 and 38. at line 1 column 46 near "));";
    62  drop table if exists tbl_decimal;
    63  drop table if exists t1;
    64  create table t1 (id int not null, str char(10));
    65  insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
    66  select * from t1 where str is null;
    67  id	str
    68  1	null
    69  2	null
    70  select * from t1 where str is not null;
    71  id	str
    72  3	foo
    73  4	bar
    74  drop table if exists t1;
    75  drop table if exists t1;
    76  drop table if exists t2;
    77  create table t1 (dt datetime not null, t datetime not null);
    78  create table t2 (dt datetime not null);
    79  insert into t1 values ('2001-01-01 1:1:1', '2001-01-01 1:1:1'),
    80  ('2001-01-01 1:1:1', '2001-01-01 1:1:1');
    81  insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1');
    82  SELECT outr.dt FROM t1 AS outr WHERE outr.dt IN (SELECT innr.dt FROM t2 AS innr WHERE outr.dt IS NULL );
    83  dt
    84  drop table if exists t1;
    85  drop table if exists t2;
    86  create table t1 (id int not null, str char(10), index(str));
    87  insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar");
    88  select * from t1 where str is not null order by id;
    89  id	str
    90  3	foo
    91  4	bar
    92  select * from t1 where str is null;
    93  id	str
    94  1	null
    95  2	null
    96  drop table if exists t1;
    97  create table t1 (a int, key (a));
    98  insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
    99  (10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
   100  select * from t1 where not(a is null);
   101  a
   102  0
   103  1
   104  2
   105  3
   106  4
   107  5
   108  6
   109  7
   110  8
   111  9
   112  10
   113  11
   114  12
   115  13
   116  14
   117  15
   118  16
   119  17
   120  18
   121  19
   122  select * from t1 where not(a is not null);
   123  a
   124  null
   125  drop table if exists t1;
   126  drop table if exists t1;
   127  CREATE TABLE t1 (a INT);
   128  INSERT INTO t1 VALUES (1),(NULL);
   129  UPDATE t1 SET a = 2 WHERE a IS NULL;
   130  select * from t1;
   131  a
   132  1
   133  2
   134  drop table if exists t1;
   135  drop table if exists t1;
   136  drop table if exists t2;
   137  drop table if exists t3;
   138  create table t1 (a int, b int);
   139  create table t2 (a int, b int);
   140  insert into t1 values (1,1),(2,1),(3,1);
   141  insert into t2 values (1,1), (3,1);
   142  select t1.a, t1.b,t2.a, t2.b from t1 left join t2  on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL;
   143  a	b	a	b
   144  1	1	1	1
   145  2	1	null	null
   146  3	1	3	1
   147  drop table if exists t1;
   148  drop table if exists t2;
   149  drop table if exists t3;
   150  drop table if exists t1;
   151  drop table if exists t2;
   152  drop table if exists t3;
   153  CREATE TABLE t1 (
   154  grp int(11) default NULL,
   155  a bigint(20) unsigned default NULL,
   156  c char(10) NOT NULL default ''
   157  );
   158  INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,'');
   159  create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a));
   160  insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7);
   161  select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null;
   162  grp	a	c	id	a	c	d
   163  2	2	b	null	null	null	null
   164  2	3	c	null	null	null	null
   165  null	null		null	null	null	null
   166  select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a and t2.id is null);
   167  grp	a	c	id	a	c	d
   168  1	1	a	null	null	null	null
   169  2	2	b	null	null	null	null
   170  2	3	c	null	null	null	null
   171  3	4	E	null	null	null	null
   172  3	5	C	null	null	null	null
   173  3	6	D	null	null	null	null
   174  null	null		null	null	null	null
   175  drop table if exists t1;
   176  drop table if exists t2;
   177  drop table if exists t3;
   178  CREATE TABLE t1 (
   179  id smallint(5) unsigned NOT NULL,
   180  name char(60) DEFAULT '' NOT NULL,
   181  PRIMARY KEY (id)
   182  );
   183  INSERT INTO t1 VALUES (1,'Antonio Paz');
   184  INSERT INTO t1 VALUES (2,'Lilliana Angelovska');
   185  INSERT INTO t1 VALUES (3,'Thimble Smith');
   186  CREATE TABLE t2 (
   187  id smallint(5) unsigned NOT NULL,
   188  owner smallint(5) unsigned DEFAULT 0 NOT NULL,
   189  name char(60),
   190  PRIMARY KEY (id)
   191  );
   192  INSERT INTO t2 VALUES (1,1,'El Gato');
   193  INSERT INTO t2 VALUES (2,1,'Perrito');
   194  INSERT INTO t2 VALUES (3,3,'Happy');
   195  select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
   196  name	name	id
   197  Lilliana Angelovska	null	null
   198  select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null;
   199  name	name	id
   200  Lilliana Angelovska	null	null
   201  select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
   202  name	name	id
   203  Lilliana Angelovska	null	null
   204  select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null;
   205  name	name	id
   206  Lilliana Angelovska	null	null
   207  drop table if exists t1;
   208  drop table if exists t2;
   209  drop table if exists t3;
   210  CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT);
   211  INSERT INTO t1 VALUES (1,'a',1);
   212  INSERT INTO t1 VALUES (2,'b',1);
   213  INSERT INTO t1 VALUES (3,'c',2);
   214  CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1));
   215  INSERT INTO t2 VALUES (1,'x');
   216  INSERT INTO t2 VALUES (2,'y');
   217  INSERT INTO t2 VALUES (3,'z');
   218  SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL;
   219  id2
   220  3
   221  SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL;
   222  id2
   223  3
   224  drop table if exists t1;
   225  drop table if exists t2;
   226  drop table if exists t3;
   227  CREATE TABLE t1 (
   228  id int(11),
   229  pid int(11),
   230  rep_del tinyint(4)
   231  );
   232  INSERT INTO t1 VALUES (1,NULL,NULL);
   233  INSERT INTO t1 VALUES (2,1,NULL);
   234  select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL;
   235  id	pid	rep_del	id	pid	rep_del
   236  1	null	null	2	1	null
   237  2	1	null	null	null	null
   238  select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL;
   239  id	pid	rep_del	id	pid	rep_del
   240  1	null	null	2	1	null
   241  2	1	null	null	null	null
   242  drop table if exists t1;
   243  drop table if exists t1;
   244  drop table if exists t2;
   245  drop table if exists t3;
   246  CREATE TABLE t1 (a DATE NOT NULL, b INT);
   247  INSERT INTO t1 VALUES ('1999-05-100',1), ('1999-05-10',2);
   248  invalid argument parsedate, bad value 1999-05-100
   249  CREATE TABLE t2 (a DATETIME NOT NULL, b INT);
   250  INSERT INTO t2 VALUES ('1999-05-10 00:01:01',1), ('1999-05-10 00:00:00',2);
   251  SELECT * FROM t1 WHERE a IS NULL;
   252  a	b
   253  SELECT * FROM t2 WHERE a IS NULL;
   254  a	b
   255  SELECT * FROM t1 LEFT JOIN t1 AS t1_2 ON 1 WHERE t1_2.a IS NULL;
   256  a	b	a	b
   257  SELECT * FROM t2 LEFT JOIN t2 AS t2_2 ON 1 WHERE t2_2.a IS not NULL;
   258  a	b	a	b
   259  1999-05-10 00:01:01	1	1999-05-10 00:00:00	2
   260  1999-05-10 00:01:01	1	1999-05-10 00:01:01	1
   261  1999-05-10 00:00:00	2	1999-05-10 00:00:00	2
   262  1999-05-10 00:00:00	2	1999-05-10 00:01:01	1
   263  SELECT * FROM t1 JOIN t1 AS t1_2 ON 1 WHERE t1_2.a IS NULL;
   264  a	b	a	b
   265  SELECT * FROM t2 JOIN t2 AS t2_2 ON 1 WHERE t2_2.a IS not NULL;
   266  a	b	a	b
   267  1999-05-10 00:00:00	2	1999-05-10 00:01:01	1
   268  1999-05-10 00:01:01	1	1999-05-10 00:01:01	1
   269  1999-05-10 00:00:00	2	1999-05-10 00:00:00	2
   270  1999-05-10 00:01:01	1	1999-05-10 00:00:00	2
   271  drop table if exists t1;
   272  drop table if exists t2;
   273  drop table if exists t3;
   274  drop table if exists t1;
   275  create table t1 (col1 datetime);
   276  insert into t1 values("2004-10-31 15:30:00");
   277  insert into t1 values("2004-12-12 11:22:33");
   278  insert into t1 values("2004-12-12 10:22:59");
   279  insert into t1 values(null);
   280  select count(*) from t1 where YEAR(col1) IS NULL;
   281  count(*)
   282  1
   283  select count(*) from t1 where YEAR(col1) IS not NULL;
   284  count(*)
   285  3
   286  drop table if exists t1;
   287  drop table if exists t1;
   288  drop table if exists t2;
   289  drop table if exists t3;
   290  create table t1 (id int(10) not null, cur_date datetime not null);
   291  create table t2 (id int(10) not null, cur_date date not null);
   292  insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22');
   293  insert into t2 (id, cur_date) values (1, '2007-04-25');
   294  select * from t1
   295  where id in (select id from t1 as x1 where (t1.cur_date is null));
   296  id	cur_date
   297  select * from t2
   298  where id in (select id from t2 as x1 where (t2.cur_date is null));
   299  id	cur_date
   300  insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22');
   301  insert into t2 (id, cur_date) values (2, '2007-04-26');
   302  select * from t1
   303  where id in (select id from t1 as x1 where (t1.cur_date is null));
   304  id	cur_date
   305  select * from t2
   306  where id in (select id from t2 as x1 where (t2.cur_date is null));
   307  id	cur_date
   308  drop table if exists t1;
   309  drop table if exists t2;
   310  drop table if exists t3;
   311  CREATE TABLE `t1` (
   312  `numeropost` int(8) unsigned NOT NULL,
   313  `maxnumrep` int(10) unsigned NOT NULL default 0,
   314  PRIMARY KEY  (`numeropost`)
   315  ) ;
   316  INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
   317  CREATE TABLE `t2` (
   318  `mot` varchar(30) NOT NULL default '',
   319  `topic` int(8) unsigned NOT NULL default 0,
   320  `dt` date,
   321  `pseudo` varchar(35) NOT NULL default '',
   322  PRIMARY KEY  (`topic`)
   323  ) ;
   324  INSERT INTO t2 (mot,topic,dt,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
   325  SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic is null);
   326  mot	topic	dt	pseudo
   327  SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
   328  mot	topic	dt	pseudo
   329  SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic is not null);
   330  mot	topic	dt	pseudo
   331  joce	40143	2002-10-22	joce
   332  joce	43506	2002-10-22	joce
   333  SELECT * from t2 where topic NOT IN (SELECT topic FROM t2 GROUP BY topic HAVING topic is null);
   334  mot	topic	dt	pseudo
   335  joce	40143	2002-10-22	joce
   336  joce	43506	2002-10-22	joce
   337  drop table if exists t1;
   338  drop table if exists t2;
   339  drop table if exists t3;
   340  CREATE TABLE t1 (a varchar(10), PRIMARY KEY (a));
   341  CREATE TABLE t2 (a varchar(10), b date, PRIMARY KEY(a));
   342  INSERT INTO t1 VALUES ('test1');
   343  INSERT INTO t2 VALUES('test1','2016-12-13'),('test2','2016-12-14'),('test3','2016-12-15'),('test4',NULL),('test5',NULL);
   344  SELECT b,
   345  CASE  WHEN b is NULL then 'found' ELSE 'not found' END FROM t2;
   346  b	CASE  WHEN b is NULL then 'found' ELSE 'not found' END
   347  2016-12-13	not found
   348  2016-12-14	not found
   349  2016-12-15	not found
   350  null	found
   351  null	found
   352  SELECT b,
   353  CASE  WHEN b is not NULL then 'found' ELSE 'not found' END FROM t2;
   354  b	CASE  WHEN b is not NULL then 'found' ELSE 'not found' END
   355  2016-12-13	found
   356  2016-12-14	found
   357  2016-12-15	found
   358  null	not found
   359  null	not found
   360  select (null) is unknown;
   361  (null)
   362  true
   363  select null is unknown;
   364  null
   365  true
   366  select true is unknown;
   367  true
   368  false
   369  select false is unknown;
   370  false
   371  false
   372  drop table if exists t1;
   373  CREATE TABLE t1 (a bool);
   374  insert into t1 values (false), (null), (true), (null);
   375  select a is unknown from t1 order by a;
   376  a
   377  true
   378  true
   379  false
   380  false
   381  select null is false;
   382  null
   383  false
   384  select null is true;
   385  null
   386  false
   387  select null is not false;
   388  null
   389  true
   390  select null is not true;
   391  null
   392  true
   393  select 1 is true;
   394  1
   395  true
   396  select 1 is false;
   397  1
   398  false
   399  select 1 is not true;
   400  1
   401  false
   402  select 1 is not false;
   403  1
   404  true
   405  select a is true from t1 order by a;
   406  a
   407  false
   408  false
   409  false
   410  true