Graph Query Language
≈ 6 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
GQL (Graph Query Language) is a standardized query language for property graphs first described in ISO/IEC 39075, released in April 20241 by ISO/IEC.
GQL (Graph Query Language) is a standardized query language for property graphs first described in ISO/IEC 39075, released in April 2024 by ISO/IEC.
Extending existing graph query languages
The GQL project draws on multiple sources or inputs, notably existing industrial languages and a new section of the SQL standard. In preparatory discussions within WG3 surveys of the history and comparative content of some of these inputs were presented. GQL is a declarative language with its own distinct syntax, playing a similar role to SQL in the building of a database application. Other graph query languages have been defined which offer direct procedural features such as branching and looping (Apache Tinkerpop's Gremlin ), and GSQL, making it possible to traverse a graph iteratively to perform a class of graph algorithms, but GQL will not directly incorporate such features. However, GQL is envisaged as a specific case of a more general class of graph languages, which share a graph type system and a calling interface for procedures that process graphs.
Querying with visual path patterns
Cypher uses compact fixed- and variable-length patterns which combine visual representations of node and relationship (edge) topologies, with label existence and property value predicates. (These patterns are usually referred to as "ASCII art" patterns, and arose originally as a way of commenting programs which used a lower-level graph API. ) By matching such a pattern against graph data elements, a query can extract references to nodes, relationships and paths of interest. Those references are emitted as a "binding table" where column names are bound to a multiset of graph elements. The name of a column becomes the name of a "binding variable", whose value is a specific graph element reference for each row of the table. For example, a pattern will generate a two-column output table. The first column named will contain references to nodes with a label . The second column named will contain references to nodes with a label , denoting the city where the person lives. The binding variables and can then be dereferenced to obtain access to property values associated with the elements referred to by a variable. The example query might be terminated with a , resulting in a complete query like this: MATCH (p:Person)-[:LIVES_IN]->(c:City) RETURN p.first_name, p.last_name, c.name, c.state This would result in a final four-column table listing the names of the residents of the cities stored in the graph. Pattern-based queries are able to express joins, by combining multiple patterns which use the same binding variable to express a natural join using the clause: MATCH (p:Person)-[:LIVES_IN]->(c:City), (p:Person)-[:NATIONAL_OF]->(EUCountry) RETURN p.first_name, p.last_name, c.name, c.state This query would return the residential location only of EU nationals. An outer join can be expressed by : MATCH (p:Person)-[:LIVES_IN]->(c:City) OPTIONAL MATCH (p:Person)-[:NATIONAL_OF]->(ec:EUCountry) RETURN p.first_name, p.last_name, c.name, c.state, ec.name This query would return the city of residence of each person in the graph with residential information, and, if an EU national, which country they come from. Queries are therefore able to first project a sub-graph of the graph input into the query, and then extract the data values associated with that subgraph. Data values can also be processed by functions, including aggregation functions, leading to the projection of computed values which render the information held in the projected graph in various ways. Following the lead of G-CORE and Morpheus, GQL aims to project the sub-graphs defined by matching patterns (and graphs then computed over those sub-graphs) as new graphs to be returned by a query. From a broad perspective, GQL monitors three key elements during query evaluation and execution: the active graph - the property graph currently being used for pattern matching; the active table - where computed information up to this point is stored; and the active record - which holds the result tuple currently in use. Patterns of this kind have become pervasive in property graph query languages, and are the basis for the advanced pattern sub-language being defined in SQL/PGQ, which is likely to become a subset of the GQL language. Cypher also uses patterns for insertion and modification clauses ( and ), and proposals have been made in the GQL project for collecting node and edge patterns to describe graph types.
Cypher 9 and Cypher 10
The current version of Cypher (including the temporal extension) is referred to as Cypher 9. Prior to the GQL project it was planned to create a new version, Cypher 10 [REF HEADING BELOW], that would incorporate features like schema and composable graph queries and views. The first designs for Cypher 10, including graph construction and projection, were implemented in the Cypher for Apache Spark project starting in 2016.
G-CORE
G-CORE is a research language designed by a group of academic and industrial researchers and language designers which draws on features of Cypher, PGQL and SPARQL. The project was conducted under the auspices of the Linked Data Benchmark Council (LDBC), starting with the formation of a Graph Query Language task force in late 2015, with the bulk of the work of paper writing occurring in 2017. G-CORE is a composable language which is closed over graphs: graph inputs are processed to create a graph output, using graph projections and graph set operations to construct the new graph. G-CORE queries are pure functions over graphs, having no side effects, which mean that the language does not define operations which mutate (update or delete) stored data. G-CORE introduces views (named queries). It also incorporates paths as elements in a graph ("paths as first class citizens"), which can be queried independently of projected paths (which are computed at query time over node and edge elements). G-CORE has been partially implemented in open-source research projects in the LDBC GitHub organization.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1375066203 under CC BY-SA 4.0; modifications have been made.