Documentation
¶
Overview ¶
Package mssql provides direct lineage analysis for T-SQL (Microsoft SQL Server) queries.
It is built on github.com/bytebase/omni's T-SQL parser and typed AST, and is a port rather than a dialect copy: a set operation is not a node of its own but fields on SelectStmt (Op/All/Larg/Rarg), a relation's qualifier is its schema, and every query body — a derived table, an expression subquery, a CTE — arrives typed, so there is no raw text to re-parse the way StarRocks has to.
Three upstream AST facts shape the traversal and are recorded in .agents/docs/mssql-lineage.md: `SelectStmt.All` doubles as SELECT ALL, so it means "keeps duplicates" only when Op is set; a scalar subquery, an aliased table reference and every declared name list carry no end offset; and two keywords are read as aliases (`FROM t1 NATURAL JOIN t2`, `MERGE INTO tgt USING src`), which is why relationAlias confirms an alias against the source text. No issue, patch or report is filed against the upstream module; see .agents/docs/omni-upstream-defects.md.
A statement kind the analyzer cannot represent is reported as a structured gap beside the edges it did find, so a coverage gap never reads as "no lineage" and never discards edges that are right.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Registration ¶
func Registration() lineage.EngineRegistration
Registration binds MSSQL to the analyzer this package provides. The process assembles the registered engines where it is built, so this package does not register itself into package state.
func SplitStatements ¶
SplitStatements splits a T-SQL script into the statements it contains, dropping the ones that carry no SQL.
The parse is the primary splitter rather than a lexical scan, because T-SQL settles two things only a parser can: a `;` inside a CREATE PROCEDURE body ends a statement inside the batch, not the batch, and `GO` is a client-side batch separator that is neither a terminator nor SQL. The analyzer is handed one statement at a time, so a script the parser accepts is cut exactly the way the parser saw it.
A script the parser rejects falls back to a lexical scan. That fallback is the whole point of the split contract: a splitter that returned nothing for unparseable text would turn "could not analyze" into the silent answer "this script has no lineage" (see backend/plugin/lineage/lineage.go).
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer analyzes one T-SQL statement.
func NewAnalyzer ¶
NewAnalyzer creates a T-SQL lineage analyzer for a single statement.
func (*Analyzer) AnalyzeRelations ¶
func (a *Analyzer) AnalyzeRelations() ([]model.ColumnRelation, error)
AnalyzeRelations parses the SQL and returns its column relations.
Parsing is strict: a statement omni cannot parse is an error, never a partial result. Multi-statement input is rejected because the analyzer is defined for exactly one statement; the caller splits a script and analyzes it statement by statement.