postgresql

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package postgresql provides direct lineage analysis for PostgreSQL queries.

This implementation is built on github.com/bytebase/omni's PostgreSQL parser and typed AST (see .agents/docs/lineage-analyzer.md). It replaced the legacy ANTLR implementation, which was parity-verified against this one over the golden corpus and then removed.

Expression classification is structural (see .agents/docs/lineage-semantics.md), and the analysis mechanism this package shares with the other dialects lives in backend/plugin/lineage/algorithm (see .agents/docs/lineage-semantics.md for what a Transformation does and does not express).

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)

func Registration

func Registration() lineage.EngineRegistration

Registration binds PostgreSQL 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 script into its individual statements, dropping the ones that carry no SQL. The caller feeds them to Analyze one at a time: this analyzer is defined for exactly one statement.

Types

type Analyzer

type Analyzer struct {
	// contains filtered or unexported fields
}

Analyzer performs direct lineage analysis on PostgreSQL queries.

func NewAnalyzer

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

NewAnalyzer creates a new PostgreSQL lineage analyzer.

func (*Analyzer) AnalyzeRelations

func (a *Analyzer) AnalyzeRelations() ([]model.ColumnRelation, error)

AnalyzeRelations parses the SQL and returns column relations.

Parse errors are a hard failure: no partial result is returned. A statement that parses but that the analyzer cannot model (MERGE) is not one — it is reported as a gap beside the edges found, so a caller records it without discarding real lineage.

The analyzer is defined for exactly one statement: the caller splits a script and feeds the statements in one at a time. A shared analyzer state across statements made an unqualified column in a later statement resolve against an earlier statement's relations, and the engines disagreed about whether a multi-statement script was accepted at all.

Jump to

Keyboard shortcuts

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