A UQL statement is structured and delivered to the Ultipa server. Then it will be parsed and optimized before being allocated to the high performance graph computing engine for graph query. The query result is processed and assembled, and finally returned to user.
This chapter will introduce the query, alias and return mechanism of UQL as a whole, with the purpose of giving a general picture. If user has doubts while reading, please continue to study the following chapters for detailed introduction to each section.
UQL Components
Check an UQL example:
find().nodes() as target return target limit 10
where:
- find().nodes() initiates a query of node;
- as target defines an alias, the query result of the previous sentence is expressed as alias "target";
- return target assembles the returned value, which is the value of "target";
- limit 10 sets the limit of the amount of data to return, here is 10 the maximum.
The green part find().nodes() is the UQL chain query styled as [command].[parameter].[parameter]...
, a complex UQL sentence may contain multiple query statements, and the result of query serves as the input and processing source of subsequent statements. Later in this chapter, the concept and usage of various query commands and their parameters will be introduced in turn.
The orange part return and limit are clause keyword. Clause is used to compute and process the result delivered from the previous statements (functional operation, aggregation, sorting, Cartesian product combination, etc.). Read chapter Data Stream, Clause for a detailed description of clause keyword.
The red part as is the alias keyword that defines alias for the current result so that it can be used in subsequent statements. Alias is link that makes various parts of UQL to work together.
UQL Prefix
UQL prefix keyword is not a mandatory component of a UQL statement. Upon the execution of a legal UQL statement, different UQL prefix can help realize different operational functions. There are 4 prefixes supported:
Prefix Keyword | Explanation | Scope |
---|---|---|
EXPLAIN | Analyze and return the operation logic tree of each chain query and clause without executing the UQL. | The whole UQL statement |
PROFILE | Execute the UQL as well as returning the operation logic structure with each chain query and clause and their engine cost. | The whole UQL statement |
DEBUG | Execute the UQL as well as returning the engine cost of each execution phase | The whole UQL statement |
EXEC TASK | Execute the UQL by sending it to analytic server (see Task - Analytics Server for detail) | The whole UQL statement |
OPTIONAL | Execute current chain query and verify the query result of each streaming-in. For any streaming-in that finds no query result, return a pseudo node/edge/path (see examples of each query command) | Current chain query statement |