Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match子句的模式图中包含无向环的情况 #228

Open
seijiang opened this issue Jun 15, 2023 · 1 comment
Open

match子句的模式图中包含无向环的情况 #228

seijiang opened this issue Jun 15, 2023 · 1 comment
Labels
bug Something isn't working cypher the cypher query language

Comments

@seijiang
Copy link
Contributor

问题描述

子图为TuGraph提供的MovieDemo,
Cypher为"match p=(n1)-[r1]->(m:movie)<-[r2]-(n2),(n1)-[r3]->(n2) return n1.login,n2.login",
根据MovieDemo的Schema,n1和n2都只可能是user类型,所以n1.login和n2.login都不应该是"null",但是从结果看不是这样,再次测试发现很多n1,n2都是person类型,这说明(n1)-[r3]->(n2)的限制并没有被应用,从执行计划上看也是这样。

Produce Results 
    Project [n1.login,n2.login] 
        Expand(All) [m <-- n2 ] 
            Expand(All) [n1 --> m ] 
                All Node Scan [n1]

根据源码看,cypher::PatternGraph::_CollectExpandStepsByDFS的提取最大连通子图的方式本来就不支持环,对于这个cypher,它会先将{n1,r1,m}这个三元组加入,然后将{m,r2,n2}这个三元组加入,然后n1,m,n2这三个点都被访问过那么就不会加入新的三元组,所以就不会处理环。

处理意见

对于cypher::PatternGraph::_CollectExpandStepsByDFS这个函数,每次加入新的三元组的时候不应该判断邻点有没有被访问?应该判断边有没有被访问?毕竟三元组事实上是和一条边一一对应的

@wangtao9
Copy link
Contributor

wangtao9 commented Jul 4, 2023

确实存在这个问题,调整的方法我觉得应该同时判断pattern边和点有没有被访问,如果边未访问则需要添加一个expand算子,根据对面的点有没有被访问决定是expand all还是expand into操作

@qishipengqsp qishipengqsp added bug Something isn't working cypher the cypher query language labels Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cypher the cypher query language
Projects
None yet
Development

No branches or pull requests

3 participants