比较函数和运算符

运算符 描述
= 赋值运算符
/ 除法运算符
== 等于运算符
!= 不等于运算符
< 小于运算符
<= 小于或等于运算符
- 减法运算符
% 余数运算符
+ 加法运算符
* 乘法运算符
- 负号运算符
udf_is_in() 比较函数,判断值是否在指定的列表中

比较运算的结果是 truefalse

  • ==

等于。String的比较大小写敏感。不同类的值不相同:

nebula> YIELD 'A' == 'a';
==============
| ("A"=="a") |
==============
| false      |
--------------

nebula> YIELD '2' == 2;
[ERROR (-8)]: A string type can not be compared with a non-string type.
  • >

大于:

nebula> YIELD 3 > 2;
=========
| (3>2) |
=========
| true  |
---------

大于或等于:

nebula> YIELD 2 >= 2;
==========
| (2>=2) |
==========
| true   |
----------
  • <

小于:

nebula> YIELD 2.0 < 1.9;
=========================================
| (2.000000000000000<1.900000000000000) |
=========================================
| false                                 |
-----------------------------------------

小于或等于:

nebula> YIELD 0.11 <= 0.11;
========================
| (0.110000<=0.110000) |
========================
| true                 |
------------------------
  • !=

不等于:

nebula> YIELD 1 != '1';
[ERROR (-8)]: A string type can not be compared with a non-string type.
  • udf_is_in()

第一个参数为要比较的值。

nebula> YIELD udf_is_in(1,0,1,2);
======================
| udf_is_in(1,0,1,2) |
======================
| true               |
----------------------

nebula> GO FROM 100 OVER follow WHERE udf_is_in($$.player.name, "Tony Parker"); /*由于udf_is_in 后面可能变更,所以该示例可能失效。*/
===============
| follow._dst |
===============
| 101         |
---------------

nebula> GO FROM 100 OVER follow YIELD follow._dst AS id | GO FROM $-.id OVER follow WHERE udf_is_in($-.id, 102, 102 + 1);
===============
| follow._dst |
===============
| 100         |
---------------
| 101         |
---------------