TQL MANUAL

TQL Overview

The Trovares Query Language (TQL) is a query language designed to interact with the Trovares xGT platform. xGT provides property graph analytics capabilities designed to scale to very large systems.

TQL Data Types

TQL supports the following datatypes and is case-insensitive in nature

TQL Commands

TQL supports the following commands: CREATE, DROP, INGEST, EGEST, and MATCH. These commands can be grouped together based on their functions.

DDL (Data Definition Language)

COMMANDDESCRIPTION
CREATE TABLE Creates a new table and inserts it into the xGT catalog.
CREATE GRAPH (General Graph)
  • Creates vertex type and edge type instances that compose a graph.
  • The KEY of a vertex type is composed of one or more columns of any type. The remaining columns are the vertex properties.
  • Edges are identified by their SOURCE KEY (source) and TARGET KEY where each is a set of columns of the same number and type as the source and target vertex type KEY columns, respectively. The remaining columns are edge properties. The declaration of the SOURCE KEY and TARGET KEY maps the names of the columns in the edge type data to the names of the columns in the source and target vertex type data, respectively.
DROP TABLEDeletes the table if it exists and all of its rows from the xGT catalog.
DROP VERTEXDeletes the vertex if it exists type and all of its instances from the xGT catalog.
DROP EDGEDeletes the edge type if it exists and all of its instances from the xGT catalog.
DROP GRAPHDeletes the General Graph if it exists and all of its vertices and edges from the xGT catalog.

DML (Data Manipulation Language)

COMMANDDESCRIPTION
INGEST
  • Load rows from a CSV formatted file into the previously created xGT table, vertex type or edge type.
  • File must be accessible to the xGT instance on a local or network-mounted file system.
  • Files can also be a url if libcurl is added to xGT.
  • Files can also be compressed with gzip or bzip2 if zlib or libbz2 is added to xGT.
  • Data in the CSV file must be column-type compatible with the type declarations of the table.
  • A header mode exists supporting: 0 = No Header, 1 = Ignore the Header, 2 = Map the header to the schema with relaxed rules, 3 = Map, but being strict if additional columns exist they must use the IGNORE keyword, and all column must map to the schema.
EGEST
  • Save rows from a xGT table into a CSV formatted file.
  • Path must be accessible to the xGT instance on a local or network-mounted file system.
  • Data will be written as textual, comma-separated rows. Rows will be separated by a standard UNIX newline character ('\n').

Query Commands

COMMANDDESCRIPTION
MATCH
  • Executes a path query based on matching instances of the specified vertex and edge types under constraints.
  • Results are inserted as rows into the specified table. Note: A table must be created manually before the match query.

TQL Commands Syntax


CREATE TABLE

CREATE TABLE [table name] ( col type, ... )

Example:

CREATE TABLE SampleTable (col1 INT, col2 TEXT)

CREATE GRAPH (General Graph)

CREATE GRAPH [general graph name]
VERTICES ( [vertex type name I] (colName coltype,...,KEY(colName,...)), [vertex type name II] (...), ...) EDGES ( [edge type name I] ( columnName coltype,..., SOURCE KEY (edge column1 = vertex type name.vertex key AND edge column2 = vertex type name.vertex type key), TARGET KEY (edge column3 = vertex type name.vertex type key )), [edge type name II] (...),...)

Example:

CREATE GRAPH SampleGeneralGraph
  VERTICES (
    Person(personID INT, DOB date, name text, KEY(personID, DOB)) )
  EDGES (
    Parent(parentID int, childID int, parentDOB date, childDOB date,
            SOURCE KEY(parentID = Person.personID,
                       parentDOB = Person.DOB),
            TARGET KEY(childID = Person.personID,
                       childDOB = Person.DOB)) );

DROP TABLE

DROP TABLE [tableName]

Example:

DROP TABLE SampleTable

DROP VERTEX

DROP VERTEX [vertex type name]

Example:

DROP VERTEX SampleVertex

DROP EDGE

DROP EDGE [edge type name]

Example:

DROP EDGE SampleEdge

DROP GRAPH

DROP GRAPH [graph name]

Example:

DROP GRAPH SampleGraph

INGEST

INGEST HEADERMODE(N) INTO [table name] FROM [UNIX path] | "[URL path]"

INGEST INTO [table name] FROM [UNIX path] | "[URL path]"

INGEST INTO [table name] FROM "[path]", "[path]", "[path]", ...

Example:

INGEST INTO SampleTable FROM ./directory/data.txt

INGEST INTO SampleTable FROM "http://www.foo.com/directory/data.txt"

INGEST HEADERMODE(N) INTO [vertex type name] FROM [UNIX path] | "[URL path]"

INGEST INTO [vertex type name] FROM [UNIX path] | "[URL path]"

INGEST INTO [vertex type name] FROM "[path]", "[path]", "[path]", ...

Example:

INGEST INTO SampleVertex FROM ./directory/data.txt

INGEST INTO SampleVertex FROM "http://www.foo.com/directory/data.txt"

INGEST HEADERMODE(N) INTO [edge type name] FROM [UNIX path] | "[URL path]"

INGEST INTO [edge type name] FROM [UNIX path] | "[URL path]"

INGEST INTO [edge type name] FROM "[path]", "[path]", "[path]", ...

Example:

INGEST INTO SampleEdge FROM ./directory/data.txt

INGEST INTO SampleEdge FROM "http://www.foo.com/directory/data.txt"

EGEST

EGEST FROM [table name] INTO [UNIX path]

EGEST WITH HEADERS FROM [table name] INTO [UNIX path]

Example:

EGEST FROM SampleTable INTO ./directory/data.txt

MATCH

MATCH [Cypher path query] INTO [table name]

Example:

MATCH (s:SampleVertex1)-[r:SampleEdge]->(d:SampleVertex2)

WHERE s.Col1 = 99

RETURN s.Col2, d.Col3

INTO ResultTable