You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "Zainab-Saad (via GitHub)" <gi...@apache.org> on 2023/03/05 13:48:21 UTC

[GitHub] [age] Zainab-Saad opened a new issue, #730: How to apply arithmetic operations on a property of variable length edge

Zainab-Saad opened a new issue, #730:
URL: https://github.com/apache/age/issues/730

   If I have a scenario in which there are three vertices A, B and C. Going from A -> B takes cost 2 and then B -> C takes cost 3. If I have to go from A -> C, I can query on the variable length edge using `()-[e:label*]->()`. But this would return the path and if we get all the intermediate edges by `relationships(p)`, we get list of edges. How do we sum the cost 2 and 3 here from this list of edges?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] jrgemignani commented on issue #730: How to apply arithmetic operations on a property of variable length edge

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #730:
URL: https://github.com/apache/age/issues/730#issuecomment-1456758028

   @Zainab-Saad @mohayu22 The sum() aggregate function only works against a column. So, it really will only sum a column of data. However, the data being returned and wanted summed is a row element that is an array of edges.
   
   Baring an existing cypher of PG function, which, off the top of my head I can't think of any, you would need to write your own function to apply against that array to return the sum.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] Zainab-Saad commented on issue #730: How to apply arithmetic operations on a property of variable length edge

Posted by "Zainab-Saad (via GitHub)" <gi...@apache.org>.
Zainab-Saad commented on issue #730:
URL: https://github.com/apache/age/issues/730#issuecomment-1455168149

   Did you try the query? Because it gives me an error `ERROR:  array index must resolve to an integer value`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] M4rcxs commented on issue #730: How to apply arithmetic operations on a property of variable length edge

Posted by "M4rcxs (via GitHub)" <gi...@apache.org>.
M4rcxs commented on issue #730:
URL: https://github.com/apache/age/issues/730#issuecomment-1465511260

   I think there's a way to achieve this, which involves writing your own function. 
   Maybe it can help you [Using Cypher](https://age.apache.org/age-manual/master/advanced/advanced.html). 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] mohayu22 commented on issue #730: How to apply arithmetic operations on a property of variable length edge

Posted by "mohayu22 (via GitHub)" <gi...@apache.org>.
mohayu22 commented on issue #730:
URL: https://github.com/apache/age/issues/730#issuecomment-1455158700

   You can use the [sum()](https://age.apache.org/age-manual/master/functions/aggregate_functions.html#sum) aggregate function to add up the cost property of each edge in the path. Here's an example query:
   ```
   WITH relationships(path) as edges
   RETURN sum(edges.cost) as total_cost
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] Zainab-Saad commented on issue #730: How to apply arithmetic operations on a property of variable length edge

Posted by "Zainab-Saad (via GitHub)" <gi...@apache.org>.
Zainab-Saad commented on issue #730:
URL: https://github.com/apache/age/issues/730#issuecomment-1483228940

   With PR # 736 being merged, the property of variable length edge can be summed as 
   `MATCH p = (a)-[e:label*]->(b)
   UNWIND (relationships(p)) AS x RETURN SUM(x.<edge_property_name>)
   `


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] Zainab-Saad closed issue #730: How to apply arithmetic operations on a property of variable length edge

Posted by "Zainab-Saad (via GitHub)" <gi...@apache.org>.
Zainab-Saad closed issue #730: How to apply arithmetic operations on a property of variable length edge 
URL: https://github.com/apache/age/issues/730


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org