IF .. THEN,
WHILE ... DO,
FOREACH ... DOstatements create a block. A
SELECTstatement also creates a block. A block-scoped variable declared inside a block scope is only accessible inside that scope.
JSONARRAYare called base type variables. The scope of a base type variable is from the point of declaration until the end of the block where its declaration took place.
=) and the desired value on the right side. You can declare multiple variables of the same type in a single declaration statement.
POST-ACCUMclause, the change will not take place until exitng the clause. Therefore, if there are multiple assignment statements for the same base type variable in an
POST-ACCUMclause, only the last one will take effect.
ACCUMclause, but the change will not take place until the clause ends. Therefore, the accumulator will not receive the value and will hold a value of 0 at the end of the query.
UPDATE SETclause, are called local base type variables.
UPDATEstatement). The lower declaration takes precedence at the lower level.
POST-ACCUMclause, each local base type variable may only be used in source vertex statements or only in target vertex statements, not both.
POST-ACCUMclause and the change will take place immediately.
SELECTstatements. Therefore, before the first
SELECTstatement in a query, a vertex set variable must be declared and initialized. This initial vertex set is called the seed set.
SetAccum<VERTEX>accumulator, untyped or typed
_(equivalent to ANY), or any explicit vertex type(s). See the EBNF grammar rule
SELECTstatement) to this vertex set variable must match the type. The following is an example in which we must declare the vertex set variable type.
personvertex. If we declare the vertex set variable
Swithout explicitly giving a type, because the type of vertex parameter
person, the GSQL engine will implicitly assign S to be
persontype. However, if
Sis assigned to
SELECTstatement inside the
WHILEloop causes a type-checking error, because the
SELECTblock will generate all connected vertices, including non-person vertices. Therefore,
Smust be declared as an ANY-type vertex set variable.
FILEobject is a sequential text storage object, associated with a text file on the local machine.
FILEobject is declared, associated with a particular text file, any existing content in the text file will be erased. During the execution of the query, content written to or printed to the
FILEobject will be appended to the
FILEobject. When the query where the
FILEobject is declared finishes running, the content of the
FILEobject is saved to the text file.
POST-ACCUMclause of a
SETclause of an
LOADACCUM()can initialize a global accumulator by loading data from a file.
LOADACCUM()has 3+n parameters explained in the table below, where n is the number of fields in the accumulator.
LOADACCUM()function calls. However, every
LOADACCUM()referring to the same file in the same assignment statement must use the same separator and header parameter values.
VOID) or the return value can be ignored, so the function call can be used as an entire statement. This is a Function Call Statement.
MapAccum) grow in size as data is added. Particularly for vertex-attached accumulators, if the number of vertices is large, their memory consumption can be significant. It can improve system performance to clear or reset collection accumulators during a query as soon as their data is no longer needed. Running the
reset_collection_accum(accumName)function resets the collection(s) to be zero-length (empty). If the argument is a vertex-attached accumulator, then the entire set of accumulators is reset.