From 1324474c450828de4a66ae940d9904c690d282af Mon Sep 17 00:00:00 2001 From: Wey Gu Date: Sat, 7 Oct 2023 23:20:15 -0700 Subject: [PATCH] example of scope and order of variable and set operator (#3024) * example of scope and order of variable and set operator * Update docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md --------- Co-authored-by: abby.huang <78209557+abby-cyber@users.noreply.github.com> --- .../2.user-defined-variables.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md index 216ba17cf1c..c2306fa527b 100644 --- a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md +++ b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md @@ -48,3 +48,18 @@ nebula> $var = GO FROM "player100" OVER follow YIELD dst(edge) AS id; \ | "Spurs" | "Manu Ginobili" | +-----------+-----------------+ ``` + +## 集合运算与变量语句的范围与运算顺序 + +当我们需要对集合运算的复合语句进行变量赋值时,需要注意用括号包裹语句的范围,比如下边的例子里`$var`赋值的来源是两个语句`INTERSECT`之后的输出。 + +```ngql +$var = ( \ + GO FROM "player100" OVER follow \ + YIELD dst(edge) AS id \ + INTERSECT \ + GO FROM "player100" OVER follow \ + YIELD dst(edge) AS id \ + ); \ + GO FROM $var.id OVER follow YIELD follow.degree AS degree +```