Newline sends an incomplete query off to query analyzer?

Another two things surprising me with GSQL.

A.
I’m taking the hello example

When I start GSQL and enter just the first line from the example, GSQL immediately comes back with an error::

GSQL-Dev > CREATE QUERY hello(VERTEX<person> p) FOR GRAPH social{

Encountered "<EOF>" at line 1, column 54.

Was expecting:

"}" ...

It seems to me that the query analyzer should recognize that I haven’t finished entering my query yet.

It works if I put everything on one line:

GSQL-Dev > CREATE QUERY hello(VERTEX<person> p) FOR GRAPH social{  Start = {p};  Result = SELECT tgt  FROM Start:s-(friendship:e) ->person:tgt;  PRINT Result; }
The query hello has been added!

but that’s seems ugly.

Does that mean I just have to put my entire query into a file in order to create it?

This doesn’t seem to be documented anywhere that I could find…

B.
The query is declared to take an argument of a Vertex of a type person. However, in the actual execution, the query is passed a STRING.

RUN QUERY hello("Tom")

Somehow a step is skipped. Is the string implicitly used as a primary key for the vertex?

(I’ll need to figure out how to manage the query if the argument is not the primary id for a vertex.)

For question A you can take a look at the BEGIN/END keywords in our documentation here at [1].

For question B, I’d like to highlight this section of documentation at [2]: "If the vertex type is specified in the query definition, then the vertex argument is vertex_id"

Where, per [3], the vertex ID is the first listed attribute on the vertex schema.

[1] https://docs.tigergraph.com/dev/gsql-ref/ddl-and-loading/system-and-language-basics#multi-line-mode-begin-end-abort
[2] https://docs.tigergraph.com/dev/gsql-ref/querying/query-operations#complex-type-parameter-passing
which says:
[3] https://docs.tigergraph.com/dev/gsql-ref/ddl-and-loading/defining-a-graph-schema#create-vertex

1 Like