name
. It can be a sequence of letters, digits, or underscores ("_"
). Other punctuation characters are not supported. The initial character can only be a letter or an underscore.baseType
). The other independent types are FILE
and STRING COMPRESS
. The remaining types are either compound data types built from the independent data types, or supersets of other types. The table below gives an overview of their definitions and their uses.baseType
INT
, UINT
, FLOAT
, DOUBLE
, STRING
, BOOL
, DATETIME,
VERTEX
, EDGE
,
JSONOBJECT
, or JSONARRAY
tupleType
accumType
FILE
FILE
objectparameterType
baseType
(except EDGE
or JSONOBJECT
), a set or bag of baseType
, or FILE
objectSTRING COMPRESS
elementType
baseType
, STRING COMPRESS
, or identifierSetAccum
, BagAccum
, GroupByAccum
, key of a MapAccum
elementtype
baseType
, STRING COMPRESS
, identifier, or accumType
ListAccum
, value of a MapAccum
elementINT
, UINT
, FLOAT
, DOUBLE
, BOOL
, STRING
, and DATETIME
) are the same ones mentioned in the "Attribute Data Types" section of GSQL Language Reference, Part 1.INT
0
-3
UINT
0
5
FLOAT
0
3.14159
DOUBLE
0
FLOAT
BOOL
false
TRUE
or FALSE
STRING
""
"Hello"
DATETIME
1970-01-01 00:00:00
VERTEX
"Unknown"
EDGE
{}
JSONOBJECT
{}
JSONARRAY
[]
FLOAT
and DOUBLE
input values must be in fixed point d.dddd
** **format, where d
is a digit. Output values will be printed in either fixed point for exponential notation, whichever is more compact.VERTEX
is considered a base type in the GSQL query language. Both query parameters and variables in a query body can be of type VERTEX
.<>
after the keyword VERTEX
. A vertex variable declared without a specifier is called a generic vertex variable.type
. The built-in attribute is of type string. You can access it with the dot (.
) operator.VERTEX<person> personVertex
, then personVertex.type
returns "person"
.EDGE
is considered a base type in the GSQL query language. Both query parameters and variables in a query body can be of type EDGE
.<>
after the keyword EDGE
. An edge variable declared without a specifier is called a generic edge variable.type
. The built-in attribute is of type string. You can access it with the dot (.
) operator.EDGE<friendship> friendEdge
, then friendEdge.type
returns "Friendship"
.INT
INT
UINT
UINT
FLOAT
FLOAT
DOUBLE
DOUBLE
BOOL
BOOL
STRING
STRING
STRING COMPRESS
STRING
SET< type >
SetAccum< type >
LIST< type >
ListAccum< type >
MAP <key_type, value_type>
MapAccum <key_type, value_type>
DATETIME
DATETIME
SET
and LIST
literalsSET
(vertex sets are an exception), LIST
, or MAP
types. However, one can still use SET
and LIST
literals to update the value of a vertex attribute of type SET
or LIST
, insert a vertex or edge with attributes of type SET
or LIST
, and initialize an accumulator.MAP
literals.JSONOBJECT
and JSONARRAY
JSONOBJECT
instance's external representation (as input and output) is a string, starting and ending with curly braces ( {}
) which enclose an unordered list of key-value_** _pairs. A JSONARRAY
is represented as a string, starting and ending with square brackets ([]
)which enclose an ordered list of values. Since a _value **_can be an object or an array, JSON supports hierarchical, nested data structures.JSONOBJECT
or JSONARRAY
value is immutable. No operator is allowed to modify its value.TYPEDEF
statement. Tuples must be defined first, before any other statements in a query.person
contains two complex attributes:secretInfo
of type SECRET_INFO
, which a user-defined tupleportfolio
of type MAP<STRING, DOUBLE>
SECRET_INFO
tuple and the portfolio MAP. The tuple type does not need to redefine SECRET_INFO
. To read and save the map, we define a MapAccum
with the same types for key and value as the portfolio
attribute. In addition, the query creates a new tuple type, ORDER_RECORD
.STRING COMPRESS
STRING COMPRESS
is an integer type encoded by the system to represent string values. STRING COMPRESS
uses less memory than STRING
. The STRING COMPRESS
type is designed to act like STRING
: data are loaded and printed just as string data, and most functions and operators which take STRING
input can also take STRING COMPRESS
input. The difference is in how the data are stored internally. A STRING COMPRESS
value can be obtained from a STRING_SET COMPRESS
or STRING_LIST COMPRESS
attribute or from converting a STRING
value.STRING COMPRESS
instead of STRING
is a trade-off: smaller storage vs. slower access times. The storage space will only be smaller if (1) the original strings are long, and (2) there are only a small number of different strings. Performance will always be slower; the slowdown is greater if the STRING COMPRESS
attributes are accessed more often.
We recommend performing comparison tests for both performance and memory usage before settling on STRING COMPRESS
.STRING COMPRESS
type is beneficial for sets of string values when the same values are used multiple times. In practice, STRING COMPRESS
are most useful for container accumulators like ListAccum<STRING COMPRESS>
or SetAccum<STRING COMPRESS>
.STRING COMPRESS
stores the dictionary when it is assigned an attribute value or from another accumulator containing STRING COMPRESS
. An accumulator containing STRING COMPRESS
can store multiple dictionaries. A STRING
value can be converted to a STRING COMPRESS
value only if the value is in the dictionaries. If the STRING
value is not in the dictionaries, the original string value is saved. A STRING COMPRESS
value can be automatically converted to a STRING
value.STRING COMPRESS
is not a base type.FILE
ObjectFILE
object is a sequential data storage object, associated with a text file on the local machine.FILE
object, we always capitalize the word FILE
to distinguish it from ordinary files.FILE
object 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 the FILE
will be appended to the FILE
. When the query where the FILE
was declared finishes running, the FILE
contents are saved to the text file.FILE
object can be passed as a parameter to another query. When a query receives a FILE
object as a parameter, it can append data to that FILE
, as can every other query which receives this FILE
object as a parameter.EDGE
, JSONARRAY
, or JSONOBJECT
). A parameter can also be a SET
or BAG
which uses base type (except EDGE
, JSONARRAY
, or JSONOBJECT
) as the element type. A FILE
object can also be a parameter. Within the query, SET
and BAG
are converted to SetAccum
and BagAccum
, respectively.FILE
object is a special case. It is passed by reference, meaning that the receiving query gets a link to the original FILE
object. The receiving query can write to the FILE
object.