`all()` returns `null` instead of `false` when a leading `null` element is followed by `false`
Reporter: ting668
Environment
- OS: Linux (WSL2 host); NebulaGraph services inside Docker containers
- Docker images:
vesoft/nebula-graphd:v3.8.0,vesoft/nebula-metad:v3.8.0,vesoft/nebula-storaged:v3.8.0(Docker Compose) - NebulaGraph Version:
3.8.0(Git7458486)
Description
While testing NebulaGraph using an intuitive approach inspired by attribute constraints, I found that the all() list predicate returns null as soon as the list contains a null element, so a later definite false is never observed.
Under Cypher's three-valued logic, all(x IN list WHERE x) must be false when the inner predicate is definitely false for at least one element, even if other elements are null. In the example below the list [NULL, false] contains a definite false, so the result should be false; NebulaGraph returns null. The equivalent expression NOT any(x IN [NULL, false] WHERE NOT x) evaluated in the same query returns false, so the two forms disagree within a single row.
How to Reproduce and Expected Behavior
Note: The queries below are a minimized, simplified example reproducing the bug.
Buggy query (no data needed):
RETURN all(x IN [NULL,false] WHERE x) AS actual,
NOT any(x IN [NULL,false] WHERE NOT x) AS oracle;Expected behavior: the list contains a definite false, so all(...) is false:
actual=false, oracle=falseActual behavior: all(...) returns null while the equivalent any() form in the same row returns false:
actual=NULL, oracle=falseThis also affects WHERE filtering. With a tag demo (name: STRING, flag: BOOL) and the two vertices below:
CREATE SPACE repro(partition_num=1,replica_factor=1,vid_type=FIXED_STRING(32));
USE repro;
CREATE TAG demo(name string, flag bool);
-- Wait for the schema to propagate to storage via heartbeat before inserting.
INSERT VERTEX demo(name,flag) VALUES "vfalse":("vfalse",false), "vtrue":("vtrue",true);
MATCH (v:demo) WHERE NOT all(x IN [NULL, v.demo.flag] WHERE x) RETURN id(v) AS id;Expected behavior: for "vfalse", flag is false, so all([NULL, false]) is false and NOT false keeps the row; for "vtrue", all([NULL, true]) is null, so that row is filtered:
id="vfalse"Actual behavior:
(empty result)This suggests that all() short-circuits to null on the first null element and never evaluates the remaining elements, so a definite false later in the list cannot produce the required false, and rows that NOT all(...) should keep are dropped.
Source: vesoft-inc/nebula