Star

case语句报错

nebula graph 2.0 docker
按照文档的示例执行的语句,但是报错了。

[nba]> GO FROM "player100" OVER follow \
               -> YIELD $$.player.name AS Name, \
               -> CASE $$.player.age > 35 \
               -> WHEN true THEN "Yes" \
               -> WHEN false THEN "No" \
               -> ELSE "Nah" \
               -> AS Age_above_35;
[ERROR (-7)]: SyntaxError: syntax error near `AS'

我换了个语句试了下,也不对。

[nba]> GO FROM "player100" OVER follow \
               -> YIELD $$.player.name AS Name \
               -> CASE $$.player.age > 35 \
               -> WHEN true THEN "Yes" \
               -> end
[ERROR (-7)]: SyntaxError: syntax error near `CASE'
[nba]> MATCH (v:player) WHERE v.age > 30 \
               -> RETURN v.name \
               -> case \
               ->  WHEN v.name STARTS WITH "T" THEN "Yes" \
               -> end
[ERROR (-7)]: SyntaxError: syntax error near `case'

你用的是什么版本的呢?case功能最近才merge的

nebula-graphd version Git: 0852f0e, Build Time: Nov 13 2020 02:04:53

但是我自己写的这个语句就能执行成功,所以我不认为是代码版本的问题。

[nba]> yield \
               -> case 3 \
               -> when 4 then "true" \
               -> end
+-----------------------------+
| CASE 3 WHEN 4 THEN true END |
+-----------------------------+
| NULL                        |
+-----------------------------+

你这个 case 后面没有加表达式

这次加了

[nba]> yield \
               -> case 1+3 \
               -> when 4 then "true" \
               -> end
+---------------------------------+
| CASE (1+3) WHEN 4 THEN true END |
+---------------------------------+
| "true"                          |
+---------------------------------+

那就是没问题喽?

有啊,在这里。

MATCH (v:player) WHERE v.age > 30
-> RETURN v.name
-> case
-> WHEN v.name STARTS WITH “T” THEN “Yes”
-> end
[ERROR (-7)]: SyntaxError: syntax error near `case’

上面已经回复你了,你的case 后面少了条件表达式屏幕快照 2020-11-13 17.18.55

你们文档这么写的呀

https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0/3.ngql-guide/6.funtions-and-expressions/5.case-expressions.md

文档没问题,是我没看清,case 后面允许空的,你是case 前面少了逗号。
屏幕快照 2020-11-13 17.40.02

谢谢

浙ICP备20010487号