Update target vertex on selected edges

Hi! I’m trying to run a update on an edge given the old and new values of the target on the edge. The use case is to update a reporting manager of all employees from the given ‘old manager’ to ‘new manager’. Here is the query I’m trying to use:

CREATE DISTRIBUTED QUERY Update_Reporting_Manager(VERTEX<EMPLOYEE> oldManager, VERTEX<EMPLOYEE> newManager) FOR GRAPH employee_manager_hierarchy { 
  fromMgr (EMPLOYEE) = {oldManager};
  COMP = SELECT emplyee from EMPLOYEE:emplyee - (REPORTS_TO>:e) - fromMgr
          POST-ACCUM  e.to_id = newManager.id;
}

It is failing with the compilation error:

no type can be inferred for e.to_id

Does the current version of GSQL support updates to source/ target edge attributes? Please help with the possible ways to achieve this use case

Seems like it would be way easier to just DELETE the edges from employees to the old manager, and then add in new edges to the new manager. I don’t think you can change an edge attribute to alter the vertexes that the edge is connecting - perhaps try something like this - this uses V2 syntax

EMPS = SELECT emp FROM fromMgr -(<REPORTS_TO:e)- EMPLOYEE:emp
ACCUM delete(e)
POST-ACCUM INSERT INTO REPORTS_TO VALUES (emp, newManager);

1 Like

This works perfectly! Thank you very much!

1 Like