I am using the script sql command in the console to run a batch query that selects a Person vertex then selects an Email vertex and then creates an edge HAS from person to email. When I run the command I get the following error.
Error: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.create edge has from $user to $email
Error: java.lang.IllegalArgumentException: source record is not a vertex
orientdb {db=test}> script sql
[Started multi-line command. Type just 'end' to finish and execute]
orientdb {db=test}> begin
orientdb {db=test}> let user = select from person where uid = '12345'
orientdb {db=test}> let email = select from email where email = '[email protected]'
orientdb {db=test}> let edge = create edge has from $user to $email
orientdb {db=test}> commit
orientdb {db=test}> return $edge
orientdb {db=test}> end
As far as I know both Person and Email are vertexes in the database. The data and schema was inserted using a .graphml database exported from neo4j. What is source record here ? the person ?
Why is it not being treated as a vertex ? Another thing I would like to point out is for the same records if I directly create an edge using the records' rid's, the edge between the vertexes are successfully created.
[ ] Remote
[ ] I have a distributed setup with multiple servers. How many?
[ ] I'm using the Enterprise Edition
[ ] v2.0.x - Please specify last number:
[ ] v2.2.x - Please specify last number:
[ ] Linux
[ ] Other, name?
[ ] 6
Can you check in the schema if Person has V as superclass ?

Just checked. Both Email and Person has V as their superclass.
@amyth
i think the problem is the $user variable. It is used in ODB in the context of the batch script to track the current user.
Try to use $person and tell me if it works
I see. If I change the variable name to person, I get the following error:
Error: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.create edge has from $person to $email
Error: java.lang.ClassCastException: java.lang.Integer cannot be cast to com.orientechnologies.orient.core.db.record.OIdentifiable

@amyth
that is because $email is from update.
try with select on email or use
let email= update email set email = '[email protected]' return after @this where email = '[email protected]'
@maggiolo00 Yes absolutely. Though I used the following (with upsert) as i needed create or update.
let email = update email set email = '[email protected]' upsert return after @this where email = '[email protected]'
Thanks so much for your quick responses and help.