semanticcheck

package
v0.11.773 Latest Latest
Warning

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

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

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

View Source
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

func ValidateSQL(ctx context.Context, conn interface{}, sql string) error

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.

type Status

type Status string

Status is the outcome of running or validating a single check.

const (
	StatusPassed  Status = "passed"
	StatusFailed  Status = "failed"
	StatusError   Status = "error"
	StatusSkipped Status = "skipped"
)

type Summary

type Summary struct {
	Passed  int `json:"passed"`
	Failed  int `json:"failed"`
	Errors  int `json:"errors"`
	Skipped int `json:"skipped"`
}

Summary counts results by status.

func Summarize

func Summarize(results []Result) Summary

Summarize tallies the results by status.

func (Summary) OK

func (s Summary) OK() bool

OK reports whether every result passed or was skipped.

Jump to

Keyboard shortcuts

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