0

I'm using AGViewer on cloud with AGCloud, and I can not create a Node with Label User.

I tried to create a Node with label User using the following query

Create(u:User {name: 'user1', email: 'user1@email.com', phone: '1234-5678'}) RETURN u

but I got the error: Syntax error at or near "User"

I tried to run the same query for different label it is working fine.

Create(u:Person {name: 'user1', email: 'user1@email.com', phone: '1234-5678'}) RETURN u

Output

Image showing output of Person Node

tell me what is the issue.

  • Most probably there is an existing relation with the name "User" so that when you try to create a new Label with the same name of an already existing table it throws that error because when you are creating that new label "User" it corresponds to table creating under the namespace of the graph for that label, so that I recommend you to check the current relations on your namespace and check whether that's the source of the issue or not! – Mohamed Mokhtar - rrrokhtar Jun 25 '23 at 18:57

7 Answers7

1

I do think its because "User" is a keyword in AGE. Try enclosing it in backticks.

CREATE (u:`User` {name: 'user1', email: 'user1@email.com', phone: '1234-5678'}) RETURN u

Also, its better to have meaningful name, so change of name is recommended.

Huzaifa
  • 484
  • 4
  • 8
1

This Query works as expected on Apache AGE viewer, perhaps User is a reserved keyword in AGCloud. You could try to find your way around it or simply use another Label name.

Query on AGE Viewer

0

Try it out this query:

SELECT * FROM cypher('graph_name', $$ 
    CREATE (u:User {name: 'user1', email: 'user1@email.com', phone: '1234-5678'}) 
    RETURN u
$$) AS (node agtype);
Wendel
  • 763
  • 1
  • 12
0

Its permissible in Apache Age. I guess that you have dependency error based on your entered data or you are getting a syntax error.

For creating a single vertex:

SELECT * 
FROM cypher('graph_name', $$
    CREATE (n)
$$) as (v agtype);

For creating a vertex with a label:

SELECT * 
FROM cypher('graph_name', $$
    CREATE (:Person)
$$) as (v agtype);

For creating a vertex and add labels and properties:

SELECT * 
FROM cypher('graph_name', $$
    CREATE (:Person {name: 'Andres', title: 'Developer')
$$) as (n agtype);

You can check this documentation for more information.

0

As answered by some folks, it is quite possible that User is some reserved keyword or there is an already existing relation. You are getting this error probably because when you are trying to use the word User, it is referring to the already existing keyword.

Prachi
  • 39
  • 3
0

I executed the query successfully using the label name "User" on AGE. It appears that the word "User" is not a reserved word in AGE. If you encountered an error, it might be due to another relation having the same name or it could be because "User" is a reserved word in AGCloud.

 SELECT * FROM cypher('usergraph', $$CREATE(u:User {name: 'user1', email: 'user1@email.com', phone:
'1234-5678'}) RETURN u$$) as (u agtype);

enter image description here

Abdul Manan
  • 117
  • 5
-1

To create a single vertex, you can use the following query:

SELECT *
FROM cypher('graph_name', $$
    CREATE (n)
$$) AS (v agtype);

In this case, the vertex will be labeled as "Person".

To create a vertex and add labels and properties, you can use the following query as an example:

SELECT *
FROM cypher('graph_name', $$
    CREATE (:Person {name: 'Andres', title: 'Developer'})
$$) AS (n agtype);

This query creates a vertex labeled as "Person" and assigns it properties such as "name" and "title" with corresponding values.

Remember to replace "graph_name" with the actual name of your graph.

If you need more detailed information, you can refer to the documentation for Apache Age.

Zeeshan
  • 3
  • 1