Skip to main content

Module graph_table

Module graph_table 

Source
Expand description

SQL/PGQ’s GRAPH_TABLE ( … ), rewritten before sqlparser sees it (#296).

sqlparser has no SQL/PGQ grammar, and forking it is ruled out. So, as DuckPGQ puts a grammar extension in front of DuckDB’s parser, Ursa rewrites each GRAPH_TABLE ( body ) (or GRAPH TABLE ( body )) in a statement’s text into an ordinary table function call, graph_table('body'), before the statement is parsed. The engine’s relation planner parses the body (the graph’s name, MATCH, the pattern, WHERE and COLUMNS) and plans it.

The rewrite works on sqlparser’s own tokens, so a GRAPH_TABLE inside a string or a comment is left alone, and the matching ) is found by counting brackets over tokens, which strings and comments cannot unbalance. Text outside each GRAPH_TABLE ( … ) is kept byte for byte.

Constants§

GRAPH_TABLE_FUNCTION
The table function a GRAPH_TABLE ( … ) becomes.

Functions§

rewrite_graph_tables
sql with every GRAPH_TABLE ( body ) rewritten to graph_table('body'). Text that does not tokenize is returned as it is, for the parser to report.