catalog

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: 4 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IdentifierFolding added in v0.1.2

func IdentifierFolding(ctx context.Context) bool

IdentifierFolding reports whether the analysis's engine binds identifiers case-insensitively. The zero value, false, is the strict byte comparison.

func WithAnalysisContext

func WithAnalysisContext(ctx context.Context, ac AnalysisContext) context.Context

WithAnalysisContext attaches ac to ctx so that GetTable can resolve unqualified table names against the correct instance/database/schema.

func WithIdentifierFolding added in v0.1.2

func WithIdentifierFolding(ctx context.Context) context.Context

WithIdentifierFolding records that the analysis's engine binds an identifier by its content rather than by its bytes, so a name the registry registered as `Users` is the object a statement named `users`. A dialect sets it for the engines whose identifiers are case-insensitive — T-SQL under its default collation is the one this build has — and it is the same fact that dialect applies to the scope resolver, which binds references by the rule its engine uses (`scope.SetFoldNames`). Here it reaches the registry lookup, so a name the statement spelled in another case still finds the object.

It is never set by a caller of the lineage API: the engine is the fact, and the dialect is the one place that knows it. An engine whose identifiers are case-sensitive — MySQL on a case-sensitive filesystem, PostgreSQL's quoted aliases — must not set it.

Types

type AnalysisContext

type AnalysisContext struct {
	InstanceID string
	Database   string
	Schema     string
}

AnalysisContext carries the default instance/database/schema for unqualified object identifiers produced during SQL lineage analysis.

func GetAnalysisContext

func GetAnalysisContext(ctx context.Context) (AnalysisContext, bool)

GetAnalysisContext retrieves the AnalysisContext from ctx. The second return value is false when no context has been attached.

func (AnalysisContext) Complete

Complete fills the missing parts of an identifier from the context. A SQL statement only ever names an object down to database/schema level, so the instance — and, for unqualified names, the database and schema — can only come from here. Both the lineage runner and the stateless AnalyzeSQL path use this, which is what keeps their results identical.

type Cache

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

Cache memoizes one analysis's catalog lookups.

It exists because the dialects disagreed about the cost of a lookup: PostgreSQL and StarRocks asked the catalog once per reference, so `FROM t a JOIN t b` read the same table twice, while the MySQL family asked once.

Memoizing a failure matters as much as memoizing a hit. The catalog is the only I/O an analysis performs, and a failure has to be reported once rather than once per reference that names the relation.

func NewCache

func NewCache(provide Provide) *Cache

NewCache wraps provide in a cache for one analysis. It returns nil when there is no provider, so a caller can hold the result in the field it already checks for nil instead of carrying a provider and a cache side by side.

func (*Cache) GetTable

func (c *Cache) GetTable(ctx context.Context, id model.ObjectIdentifier) (*TableMeta, error)

GetTable returns the metadata for id, consulting the wrapped provider at most once per identifier. A nil result with a nil error means the registry does not know the object, which is a normal answer: it is memoized like a hit so a relation missing from the registry does not cost a lookup per reference either.

type ColumnMeta

type ColumnMeta struct {
	Name     string
	Type     string
	Nullable bool
}

type Provide

type Provide interface {
	GetTable(ctx context.Context, id model.ObjectIdentifier) (*TableMeta, error)
}

func NewCatalogProvide

func NewCatalogProvide(store *store.Store) Provide

type TableMeta

type TableMeta struct {
	ID      model.ObjectIdentifier
	Columns []ColumnMeta
}

TableMeta is what the registry knows about a relation. ID is the identity the registry registered, which is the spelling it holds the object under: a lookup that had to fold the name answers with the registered one, so a caller records the object the registry has rather than the name the statement wrote.

Jump to

Keyboard shortcuts

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