graflo.db.tigergraph.gsql_parsers¶
Pure parsers for TigerGraph GSQL and REST catalog output.
Attributes¶
EDGE_DDL_PATTERN = re.compile('-\\s*(DIRECTED|UNDIRECTED)\\s+EDGE\\s+(\\w+)\\s*\\((.*?)\\)\\s*(?:WITH\\s+REVERSE_EDGE\\s*=\\s*\\"(\\w+)\\"|WITH\\b|$)', re.IGNORECASE | re.MULTILINE)
module-attribute
¶
LS_INSTALLED_QUERY_PATTERN = re.compile('^\\s*-\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\([^)]*\\)\\s*\\(installed', re.IGNORECASE)
module-attribute
¶
SHOW_QUERY_CREATE_PATTERN = re.compile('CREATE\\s+QUERY\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*\\(', re.IGNORECASE)
module-attribute
¶
SHOW_QUERY_INSTALLED_MARKER = re.compile('#\\s*installed', re.IGNORECASE)
module-attribute
¶
VERTEX_DDL_PATTERN = re.compile('-\\s*VERTEX\\s+(\\w+)\\s*\\((.*?)\\)\\s*(?:WITH\\b|$)', re.IGNORECASE | re.MULTILINE)
module-attribute
¶
Classes¶
GsqlAttribute
dataclass
¶
One attribute of a GSQL vertex or edge type.
Source code in graflo/db/tigergraph/gsql_parsers.py
GsqlEdgeDdl
dataclass
¶
A recovered CREATE ... EDGE declaration.
endpoints holds every FROM x, TO y pair, since a single GSQL edge
type may declare several separated by |.
Source code in graflo/db/tigergraph/gsql_parsers.py
GsqlVertexDdl
dataclass
¶
A recovered CREATE VERTEX declaration.
Source code in graflo/db/tigergraph/gsql_parsers.py
Functions:¶
forward_edge_ddl(edges)
¶
edges without the reverse types the database maintains for others.
A WITH REVERSE_EDGE pair is listed as two edge types naming each other,
and nothing in the listing says which one was authored. The one listed first
is taken as the forward type, and the type it names as its reverse is
dropped: it is derived, stores nothing of its own, and recovering it as a
second logical edge would describe one fact twice.
Source code in graflo/db/tigergraph/gsql_parsers.py
gsql_result_has_error(result)
¶
Return True when a GSQL response text signals a semantic/runtime failure.
Source code in graflo/db/tigergraph/gsql_parsers.py
is_missing_query_endpoint_error(result)
¶
Return True when REST++ reports an installed query endpoint is missing.
Source code in graflo/db/tigergraph/gsql_parsers.py
is_not_found_error(error)
¶
Return True if the error indicates that an object doesn't exist.
parse_installed_queries_from_ls(result_str)
¶
Parse ls output lines like - my_query() (installed v2).
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_installed_queries_from_rest_endpoints(result, graph_name)
¶
Extract installed query names from GET /endpoints/{graph}?dynamic=true.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_installed_queries_from_show_query(result_str)
¶
Parse SHOW QUERY * output, keeping only blocks marked # installed.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_restpp_response(response, is_edge=False)
¶
Parse REST++ API response into list of documents.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_show_edge_ddl(result_str)
¶
Recover full EDGE declarations from SHOW EDGE * output.
The UNDIRECTED keyword is the point: it is the only place any backend
states an edge is undirected, so it is the only place Edge.directed
can be recovered rather than assumed.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_show_edge_output(result_str)
¶
Parse SHOW EDGE * output to extract edge type names and direction.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_show_edge_output_with_vertices(output)
¶
Parse SHOW EDGE * output (compact TigerGraph format).
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_show_graph_output(result_str)
¶
Parse SHOW GRAPH * output to extract graph names.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_show_job_output(result_str)
¶
parse_show_output(result_str, prefix)
¶
Parse SHOW * output to extract type names.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_show_vertex_ddl(result_str)
¶
Recover full VERTEX declarations from SHOW VERTEX * output.
Source code in graflo/db/tigergraph/gsql_parsers.py
parse_show_vertex_output(result_str)
¶
rest_error_suggests_auth_or_gateway(result)
¶
Source code in graflo/db/tigergraph/gsql_parsers.py
rest_response_is_error(result)
¶
split_ddl_terms(body)
¶
Split a DDL parameter list on top-level commas and pipes.
Depth-aware because a compound type spells its arguments with commas of its
own -- MAP<INT, STRING> is one term, not two. | separates the endpoint
clauses of a multi-endpoint edge (FROM a, TO b | FROM c, TO d) and is
treated the same way, so every pair is recovered rather than just the first.