public final class PathIndex extends Object
sqllr-path-1 paths of one statement (lineage-spec/algorithms/path-v1.md).
PATH-V1 anchors a reference at "the innermost step whose construct contains the first character of the
reference" (Section 6.1), so this index records, for every step the statement emits, the text range of its
construct and its path, and answers anchor(int) by the innermost range containing an offset. Steps are
assigned top down from the parse tree with explicit work queues: the clauses of a query block and the steps of a
data-changing statement have their parent fixed by Sections 3 and 4; expression steps (FUNCTION_ARG,
CASE_*, SUBQUERY, WINDOW) take the innermost enclosing step of their clause as parent.
GSP's TParseTreeNode.parent is not used: it is set in only a few places.
Forms PATH-V1 does not cover (Section 2, item 3) are recorded as uncovered ranges; a reference inside one has
no sqllr-path-1 anchor (PathIndex.Anchor.isCovered() is false), and the producer publishes nothing anchored
there (plan 06, decision 1). A column reference that lands directly on a statement, query block or FROM-item step
sits in a clause or table modifier this index does not know (MODEL, MATCH_RECOGNIZE, SAMPLE, table hints, OUTPUT,
time travel): anchorColumn(gudusoft.gsqlparser.nodes.TObjectName) reports it uncovered rather than inventing a path.
| Modifier and Type | Class and Description |
|---|---|
static class |
PathIndex.Anchor
The anchor of an offset: a path, or the fact that it lies in an uncovered form or outside the statement.
|
| Modifier and Type | Method and Description |
|---|---|
PathIndex.Anchor |
anchor(int offset)
The anchor of the reference whose first character is at the UTF-16 offset.
|
PathIndex.Anchor |
anchor(TParseTreeNode node)
The anchor of the first token of a node.
|
PathIndex.Anchor |
anchor(TSourceToken token)
The anchor of the first character of a token.
|
PathIndex.Anchor |
anchorColumn(TObjectName column)
anchorColumn(TObjectName) of a live column reference of the tree the index was built from. |
PathIndex.Anchor |
anchorColumn(TObjectName column)
The anchor of a column reference: as
anchor(TParseTreeNode), but a column that lands directly on a
statement, query block, WITH, FROM, JOIN, TARGET or USING step is in a construct this index does not model
and is reported uncovered. |
String |
blockPath(TSelectSqlStatement block)
The path of a query block (the
QUERY_BLOCK scope path), or null when not indexed. |
String |
blockPath(TSelectSqlStatement block)
blockPath(TSelectSqlStatement) of a live query block of the tree the index was built from. |
Map<TSelectSqlStatement,String> |
blockPaths()
Every indexed query block and its path, in no particular order.
|
static PathIndex |
build(TCustomSqlStatement stmt,
SourceText text)
build(TCustomSqlStatement, SourceText, String) with no fallback statement step. |
static PathIndex |
build(TCustomSqlStatement stmt,
SourceText text)
The paths of a statement a caller holds as a live parse tree (a parse with no analysis): the tree is projected
first (plan 09, slice 1b), and the live overloads of
anchorColumn(gudusoft.gsqlparser.nodes.TObjectName) and blockPath(gudusoft.gsqlparser.lineage.v2.shape.TSelectSqlStatement) take its nodes. |
static PathIndex |
build(TCustomSqlStatement stmt,
SourceText text,
String step)
The paths of one statement.
|
static PathIndex |
buildByOffset(TCustomSqlStatement stmt,
SourceText text)
The same for a statement of dynamic SQL text: the analysis moves its tokens' lines and columns to the site, so
positions come from the tokens' offsets into the text.
|
String |
enclosingBlockPath(String path)
The innermost query block path that is a prefix of (or equal to) a path, or
null. |
String |
getDmlCtePath(TCTE cte)
The path of the step of a covered data-changing CTE's statement (CTE[c]/UPDATE[0]), or null.
|
String |
getStatementPath()
The statement step path, such as
INSERT[0], or null when the statement has none. |
boolean |
isFullyCovered()
Whether every part of the statement is in a covered form.
|
static String |
statementStep(TCustomSqlStatement stmt)
The statement step code of a statement, or
null when PATH-V1 has none for it. |
public static String statementStep(TCustomSqlStatement stmt)
null when PATH-V1 has none for it.public static PathIndex build(TCustomSqlStatement stmt, SourceText text, String step)
stmt - the statementtext - the text of the source unit the statement's tokens are positioned instep - the statement step to use when statementStep has none (COPY, CALL,
EXECUTE), or null: the statement then has no covered anchor at allpublic static PathIndex buildByOffset(TCustomSqlStatement stmt, SourceText text)
public static PathIndex build(TCustomSqlStatement stmt, SourceText text)
build(TCustomSqlStatement, SourceText, String) with no fallback statement step.public static PathIndex build(TCustomSqlStatement stmt, SourceText text)
anchorColumn(gudusoft.gsqlparser.nodes.TObjectName) and blockPath(gudusoft.gsqlparser.lineage.v2.shape.TSelectSqlStatement) take its nodes.public String getStatementPath()
INSERT[0], or null when the statement has none.public String blockPath(TSelectSqlStatement block)
QUERY_BLOCK scope path), or null when not indexed.public String blockPath(TSelectSqlStatement block)
blockPath(TSelectSqlStatement) of a live query block of the tree the index was built from.public Map<TSelectSqlStatement,String> blockPaths()
public String enclosingBlockPath(String path)
null.public boolean isFullyCovered()
public PathIndex.Anchor anchor(int offset)
public PathIndex.Anchor anchor(TSourceToken token)
public PathIndex.Anchor anchor(TParseTreeNode node)
public PathIndex.Anchor anchorColumn(TObjectName column)
anchorColumn(TObjectName) of a live column reference of the tree the index was built from.public PathIndex.Anchor anchorColumn(TObjectName column)
anchor(TParseTreeNode), but a column that lands directly on a
statement, query block, WITH, FROM, JOIN, TARGET or USING step is in a construct this index does not model
and is reported uncovered.public String getDmlCtePath(TCTE cte)