catalog

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

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
}

Jump to

Keyboard shortcuts

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