Comparison Functions and Operators¶
Name | Description |
---|---|
= | Assign a value |
/ | Division operator |
== | Equal operator |
!= | Not equal operator |
< | Less than operator |
<= | Less than or equal operator |
- | Minus operator |
% | Modulo operator |
+ | Addition operator |
* | Multiplication operator |
- | Change the sign of the argument |
udf_is_in() | Whether a value is within a set of values |
Comparison operations result in a value of true and false.
- ==
Equal. String comparisons are case-sensitive. Values of different types are not equal.
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.
- >
Greater than:
nebula> YIELD 3 > 2;
=========
| (3>2) |
=========
| true |
---------
- ≥
Greater than or equal to:
nebula> YIELD 2 >= 2;
[ERROR (-8)]: A string type can not be compared with a non-string type.
- <
Less than:
nebula> YIELD 2.0 < 1.9;
=========================================
| (2.000000000000000<1.900000000000000) |
=========================================
| false |
-----------------------------------------
- ≤
Less than or equal to:
nebula> YIELD 0.11 <= 0.11;
========================
| (0.110000<=0.110000) |
========================
|true |
------------------------
- !=
Not equal:
nebula> YIELD 1 != '1';
A string type can not be compared with a non-string type.
- udf_is_in()
Returns true if the first value is equal to any of the values in the list, otherwise, returns false.
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"); /* This example might not work because udf_is_in might be changed in the future.*/
===============
| 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 |
---------------