Equality on an `INT` property with a floating-point literal drops the matching row when a property index on that property is used (scan path returns it)
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 comparing an INT property with a floating-point literal silently drops the matching row when the query is answered through a property index on that property.
The vertex "n" has i = 3000000000, which is exactly representable in both the integer and DOUBLE domains. The query WHERE v.metric.i == 3000000000.0 returns "n" in the space whose tag index is on name, and returns empty in the space whose tag index is on the compared property i.
How to Reproduce and Expected Behavior
Note: The queries below are a minimized, simplified example reproducing the bug.
Buggy query (with the minimal setup below):
-- Space 1: tag index on name (not on the compared property i).
CREATE SPACE repro_name_idx(partition_num=1,replica_factor=1,vid_type=FIXED_STRING(32));
USE repro_name_idx;
CREATE TAG metric(name string,i int,f double);
CREATE TAG INDEX metric_idx ON metric(name(16));
-- Wait for the space, schema, and index metadata to propagate via heartbeats before inserting.
INSERT VERTEX metric(name,i,f) VALUES "n":("n",3000000000,0.0);
-- Space 2: identical schema, but the tag index is on the compared property i.
CREATE SPACE repro_i_idx(partition_num=1,replica_factor=1,vid_type=FIXED_STRING(32));
USE repro_i_idx;
CREATE TAG metric(name string,i int,f double);
CREATE TAG INDEX metric_idx ON metric(i);
-- Wait for the space, schema, and index metadata to propagate via heartbeats before inserting.
INSERT VERTEX metric(name,i,f) VALUES "n":("n",3000000000,0.0),"other":("other",0,0.0);
-- The same query in both spaces:
USE repro_name_idx;
MATCH (v:metric) WHERE v.metric.i == 3000000000.0
RETURN id(v) AS id, v.metric.i AS i ORDER BY id;
USE repro_i_idx;
MATCH (v:metric) WHERE v.metric.i == 3000000000.0
RETURN id(v) AS id, v.metric.i AS i ORDER BY id;Expected behavior: n.i is 3000000000 and the literal 3000000000.0 denotes the same exactly representable value, so only n passes the predicate in both spaces (other.i = 0 does not):
id="n", i=3000000000 (in both spaces)Actual behavior: the space with the index on name returns the row; the space with the index on the compared property i returns empty:
repro_name_idx: id="n", i=3000000000
repro_i_idx: (empty result)Control: in the space with the i index, replacing the numeric predicate with an explicit VID list still returns the row, confirming the data is present in that same space:
USE repro_i_idx;
MATCH (v:metric) WHERE id(v) IN ["n"]
RETURN id(v) AS id, v.metric.i AS i ORDER BY id;id="n", i=3000000000This suggests that the property-index path cannot evaluate the comparison between the INT property i and the floating-point literal 3000000000.0 and silently returns no rows, although 3000000000 is exactly representable in both the integer and DOUBLE domains and the same predicate returns the row on the scan-and-filter path.
Source: vesoft-inc/nebula