• 比较函数和运算符

    比较函数和运算符

    运算符 描述
    = 赋值运算符
    / 除法运算符
    == 等于运算符
    != 不等于运算符
    < 小于运算符
    <= 小于或等于运算符
    - 减法运算符
    % 余数运算符
    + 加法运算符
    * 乘法运算符
    - 负号运算符
    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.000000<1.900000) |
    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 201 OVER like WHERE udf_is_in($$.student.name, "Jane")
    8. =============
    9. | like._dst |
    10. =============
    11. | 202 |
    12. -------------
    13. nebula> GO FROM 201 OVER like YIELD like._dst AS id | GO FROM $-.id OVER like WHERE udf_is_in($-.id, 200, 200+1)
    14. =============
    15. | like._dst |
    16. =============
    17. | 201 |
    18. -------------