Skip to content

Incorrect rows with comma-separated MATCH pattern list #970

Description

@ting668

Reporter: ting668

Environment

  • OS: CentOS Linux 7 (Core), inside Docker container
  • CPU/Architecture: x86_64
  • Docker image: tugraph/tugraph-runtime-centos7:latest
  • TuGraph-DB Version: 4.5.2 (tugraph-4.5.2-1.x86_64)

Description

While testing TuGraph using a method based on attribute-constraint analysis, I found that a comma-separated MATCH pattern list can return rows that violate the label constraint.

In the example below, a is constrained to Teacher, but TuGraph returns an Actor node as a.

How to Reproduce and Expected Behavior

Note: The queries below are a minimized, simplified example reproducing the bug.

Original graph G:

CALL db.createVertexLabel('Teacher','name','name','STRING',false,'gender','STRING',true,'faculty','STRING',true);
CALL db.createVertexLabel('Student','name','name','STRING',false,'gender','STRING',true,'faculty','STRING',true);
CALL db.createVertexLabel('Actor','name','name','STRING',false,'gender','STRING',true);

CREATE (:Teacher {name:'Bob', gender:'Male', faculty:'computer'}),
       (:Actor {name:'Owen', gender:'Male'}),
       (:Student {name:'Mary', gender:'Female', faculty:'computer'}),
       (:Student {name:'Lily', gender:'Female', faculty:'computer'});

Query:

MATCH (a:Teacher {gender:'Male'}), (b:Student {gender:'Female'})
RETURN a.name, b.name;

Expected result on G:

Bob, Mary
Bob, Lily

Actual result on G:

Bob, Mary
Bob, Lily
Owen, Lily

Induced subgraph G1 using faculty = 'computer' removes the Actor node:

CALL db.createVertexLabel('Teacher','name','name','STRING',false,'gender','STRING',true,'faculty','STRING',true);
CALL db.createVertexLabel('Student','name','name','STRING',false,'gender','STRING',true,'faculty','STRING',true);

CREATE (:Teacher {name:'Bob', gender:'Male', faculty:'computer'}),
       (:Student {name:'Mary', gender:'Female', faculty:'computer'}),
       (:Student {name:'Lily', gender:'Female', faculty:'computer'});

The same query on G1 returns the expected two rows:

Bob, Mary
Bob, Lily

Equivalent query on G also returns the expected two rows:

MATCH (a:Teacher {gender:'Male'})
WITH a
MATCH (b:Student {gender:'Female'})
RETURN a.name, b.name;

Expected behavior: all equivalent formulations should return only Teacher-Student pairs.

Actual behavior: the comma-separated pattern query on G leaks the Actor node Owen into the result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions