Hi everyone, I’m less than a day new to tigergraph and am trying to understand some of the GSQL syntax. One task I am interested in is performing and INSERT and retrieving the automatically created UUID.
Here’s my attempt at it, the error makes it mostly explicit what is wrong with the query, but I still am not sure how to proceed.
CREATE VERTEX human(
UID STRING PRIMARY KEY,
first_name STRING,
last_name STRING
)
CREATE QUERY MakeHuman() FOR GRAPH people {
STRING uuid = gsql_uuid_v4();
INSERT INTO human (UID, first_name, last_name)
VALUES (uuid, "John", "Smith");
PRINT uuid;
}
This also makes me curious about the role the REST++ API serves. For example, when I create a schema, do I get a route that lets me do INSERT/SELECT for free? If so, is there documentation on that?
I am using 3.1.5 while trying out the technology for our use case’s.
The gsql_uuid function does seem to work in the query language(it compiles and can be called), but it seems to only work in the following context:
CREATE QUERY MakeHuman() FOR GRAPH people {
INSERT INTO human (UID, first_name, last_name)
VALUES (gsql_uuid_v4(), "John", "Smith");
}
Which is great, but the issue there is - I can’t insert a node and return it’s UID in one transaction. That kind of operation is pretty important too us for dynamic use of the graph. Is there an alternate means to generate read only UID’s? I saw some syntax for it using something like INSERT INTO human (PRIMARY_ID, first_name, last_name) VALUES (UID, "John", "Smith"); but I couldn’t find a means to either generate a UID instance within GSQL/TG API or get the function to compile.
if gsql_uuid_v4() doesn’t work in the query language, how is it intended to be used - is there a work around to get the behavior I am looking for? IE insert and return what was inserted.
Thanks for the information about the REST API - that could come in handy.
For data loading, I’m considering a situation where I would create several vertices from the same input line, but would need to create edges between them as well. I need to use GUIDs as the primary id/key. Do I need to first create a TEMP_TABLE and load it with the data and the GUIDs that I need for the vertices - so that a subsequent pass over the TEMP_TABLE will have all the values that it needs? [I don’t want to have to put GUIDs in the input file.] For example something like this: