比较函数和运算符

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

比较运算的结果是 truefalse

  • \==

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

  1. nebula> YIELD 'A' == 'a';
  2. ==============
  3. | ("A"=="a") |
  4. ==============
  5. | false |
  6. --------------
  7. nebula> YIELD '2' == 2;
  8. [ERROR (-8)]: A string type can not be compared with a non-string type.
  • >

大于:

  1. nebula> YIELD 3 > 2;
  2. =========
  3. | (3>2) |
  4. =========
  5. | true |
  6. ---------

大于或等于:

  1. nebula> YIELD 2 >= 2;
  2. ==========
  3. | (2>=2) |
  4. ==========
  5. | true |
  6. ----------
  • <

小于:

  1. nebula> YIELD 2.0 < 1.9;
  2. =========================================
  3. | (2.000000000000000<1.900000000000000) |
  4. =========================================
  5. | false |
  6. -----------------------------------------

小于或等于:

  1. nebula> YIELD 0.11 <= 0.11;
  2. ========================
  3. | (0.110000<=0.110000) |
  4. ========================
  5. | true |
  6. ------------------------
  • !=

不等于:

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

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

  1. nebula> YIELD udf_is_in(1,0,1,2);
  2. ======================
  3. | udf_is_in(1,0,1,2) |
  4. ======================
  5. | true |
  6. ----------------------
  7. nebula> GO FROM 100 OVER follow WHERE udf_is_in($$.player.name, "Tony Parker"); /*由于udf_is_in 后面可能变更,所以该示例可能失效。*/
  8. ===============
  9. | follow._dst |
  10. ===============
  11. | 101 |
  12. ---------------
  13. nebula> GO FROM 100 OVER follow YIELD follow._dst AS id | GO FROM $-.id OVER follow WHERE udf_is_in($-.id, 102, 102 + 1);
  14. ===============
  15. | follow._dst |
  16. ===============
  17. | 100 |
  18. ---------------
  19. | 101 |
  20. ---------------