• Return 语法
    • 示例

    Return 语法

    Return 语句用于返回条件成立时的结果。

    1. RETURN <var_ref> IF <var_ref> IS NOT NULL
    • 为变量名称,示例:$var

    示例

    1. nebula> $A = GO FROM 200 OVER follow YIELD follow._dst AS dst; \
    2. $rA = YIELD $A.* WHERE $A.dst == 201; \
    3. RETURN $rA IF $rA is NOT NULL; \ /* $rA 为非空,返回 $rA */
    4. GO FROM $A.dst OVER follow; /* 语句不执行*/
    5. ==========
    6. | $A.dst |
    7. ==========
    8. | 201 |
    9. ----------
    10. nebula> $A = GO FROM 200 OVER follow YIELD follow._dst AS dst; \
    11. $rA = YIELD $A.* WHERE $A.dst == 300; \
    12. RETURN $rA IF $rA is NOT NULL; \ /* $rA 为空,不返回任何值 */
    13. GO FROM $A.dst OVER follow;
    14. =============
    15. | follow._dst |
    16. =============
    17. | 200 |
    18. -------------
    19. | 202 |
    20. -------------