vesoft-inc / nebula

A distributed, fast open-source graph database featuring horizontal scalability and high availability
https://nebula-graph.io
Apache License 2.0
10.86k stars 1.21k forks source link

support {match UNION match UNION mathc...} with ... Return syntax #5980

Open Reid00 opened 2 days ago

Reid00 commented 2 days ago

as neo4j support below statement, we want to migrate to nebula, could you please support this syntax? detail according to here https://discuss.nebula-graph.com.cn/t/topic/15776

{ MATCH p = (self:Company)<-[sr:Invest|Legal]-(target)
 WHERE id(self)== -7835036839804393803 AND id(target)== -531217911035008506
 RETURN target, p, 'C' AS nodeType, 1 AS orderWeight 
 UNION
 MATCH p = (self:Company)<-[sr:FinalBenefit]-(target:Company)
 WHERE id(self)== -7835036839804393803 AND id(target)== -531217911035008506 AND sr.percent >= 5
 RETURN target, p, 'BE5' AS nodeType, 5 AS orderWeight 
 UNION 
 MATCH p = (self:Company)<-[sr:FinalBenefit]-(target:Person) 
 WHERE id(self)== -7835036839804393803 AND id(target)== -531217911035008506 AND sr.percent >= 5 
 RETURN target, p, 'BP5' AS nodeType, 5 AS orderWeight
 UNION
 MATCH p = (self:Company)<-[sr:Employ]-(target:Person) 
 WHERE id(self)== -7835036839804393803 AND id(target)== -531217911035008506 
 RETURN target, p, 'DJG' AS nodeType, 7 AS orderWeight 
 UNION 
 MATCH p = (self:Company)-[sr:Invest]->(target:Company) 
 WHERE id(self)== -7835036839804393803 AND id(target)== -531217911035008506
 RETURN target, p, 'HE' AS nodeType, 4 AS orderWeight }  
 WITH target, p, nodeType, orderWeight 
 RETURN target AS target, collect(p) AS path, collect(nodeType) AS nodeType, min(orderWeight) AS orderWeight, CASE target.status WHEN 'Yes' THEN 0 WHEN 'No' THEN 0 WHEN '' THEN 0 WHEN 'Yes_1' THEN 1 WHEN 'xx' THEN 1 WHEN 'xxx' THEN 10 WHEN 'xxxx' THEN 10 WHEN '***' THEN 11 WHEN '*' THEN 11 ELSE 8 END AS status ORDER BY status, orderWeight SKIP 0 LIMIT 100