mssql

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 Analyze

func Analyze(ctx context.Context, sql string, cat catalog.Provide) ([]model.ColumnRelation, error)

Analyze parses a single T-SQL statement and returns its column relations.

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

func SplitStatements(sql string) []string

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

func NewAnalyzer(ctx context.Context, sql string, catalogProvide catalog.Provide) *Analyzer

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL