Documentation
¶
Overview ¶
Package semanticcheck executes semantic layer quality checks against Bruin connections. SQL generation and pass/fail evaluation live in the semantic engine; this package only deals with connections, concurrency, and results.
Index ¶
Constants ¶
const DefaultConcurrency = 8
DefaultConcurrency is the number of checks run in parallel per Run call.
Variables ¶
This section is empty.
Functions ¶
func SortResults ¶
func SortResults(results []Result)
SortResults orders results by model, scope, target, and name so that output is deterministic regardless of execution order.
func SupportsQueries ¶
func SupportsQueries(conn interface{}) bool
SupportsQueries reports whether the connection can run the check queries.
func ValidateSQL ¶
ValidateSQL checks that a single SELECT statement is valid on conn without materializing its result. It prefers the platform dry run or EXPLAIN, which resolves tables and columns, over syntax-only validation.
Types ¶
type Result ¶
type Result struct {
ID string `json:"id"`
Model string `json:"model"`
Scope semantic.CheckScope `json:"scope"`
Target string `json:"target,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
SQL string `json:"sql"`
Status Status `json:"status"`
Message string `json:"message,omitempty"`
DurationMS int64 `json:"duration_ms"`
}
Result describes the outcome of one check.
type Runner ¶
type Runner struct {
// Concurrency limits how many checks run at the same time. Zero or
// negative values use DefaultConcurrency.
Concurrency int
}
Runner executes compiled checks.
func (*Runner) Run ¶
func (r *Runner) Run(ctx context.Context, conn interface{}, checks []semantic.CompiledCheck) []Result
Run executes every check against conn and evaluates the results. The order of the returned results matches the order of the checks.
func (*Runner) Validate ¶
func (r *Runner) Validate(ctx context.Context, conn interface{}, checks []semantic.CompiledCheck) []Result
Validate dry-runs every check against conn without evaluating data. It uses the connection's dry-run or EXPLAIN support when available and falls back to executing the query with a false predicate so that it is planned but returns no rows.