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 ¶
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 ¶
func (ac AnalysisContext) Complete(id model.ObjectIdentifier) model.ObjectIdentifier
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 ¶
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 ¶
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 Provide ¶
type Provide interface {
GetTable(ctx context.Context, id model.ObjectIdentifier) (*TableMeta, error)
}
func NewCatalogProvide ¶
type TableMeta ¶
type TableMeta struct {
ID model.ObjectIdentifier
Columns []ColumnMeta
}