coalesce 函数异常

官方文档及coalesce 使用例子在这里

但我实际运行的结果却是这样:

请问是不是有bug?

我的nebula版本是3.1的。

多谢!

恭喜你发现了一个已知的 bug,参考 issue Wrong behavior of coalesce() · Issue #4213 · vesoft-inc/nebula · GitHub 预计这个会在 v3.2.0 版本中修复哈

1 个赞

不是 bug 哈,是文档的问题,coalesce 接受的不是list,而是多参数,如果想接受 list,可以用 head(),如下。

感谢 @kyle

nebula> WITH [NULL, 4923, 'abc', 521, 487] AS ids \
        RETURN reverse(ids), tail(ids), head(ids), last(ids), coalesce(ids[0], ids[1], ids[2]), head([x IN ids WHERE x IS NOT NULL | x]);
+-----------------------------------+-------------------------+-----------+-----------+--------------------------------+--------------------------------------------------------------+
| reverse(ids)                      | tail(ids)               | head(ids) | last(ids) | coalesce(ids[0],ids[1],ids[2]) | head([__VAR_0 IN ids WHERE $__VAR_0 IS NOT NULL | $__VAR_0]) |
+-----------------------------------+-------------------------+-----------+-----------+--------------------------------+--------------------------------------------------------------+
| [487, 521, "abc", 4923, __NULL__] | [4923, "abc", 521, 487] | __NULL__  | 487       | 4923                           | 4923                                                         |
+-----------------------------------+-------------------------+-----------+-----------+--------------------------------+———————————————————————————————+

此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。