ansisql

package
v0.11.597 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultQueryAnnotations = "default"
	QueryLogCharacterLimit  = 10000
)

Variables

This section is empty.

Functions

func AddAnnotationComment added in v0.11.293

func AddAnnotationComment(ctx context.Context, q *query.Query, assetName, taskType, pipelineName string) (*query.Query, error)

func AddColumnCheckAnnotationComment added in v0.11.296

func AddColumnCheckAnnotationComment(ctx context.Context, q *query.Query, assetName, columnName, checkType, pipelineName string) (*query.Query, error)

func AddCustomCheckAnnotationComment added in v0.11.296

func AddCustomCheckAnnotationComment(ctx context.Context, q *query.Query, assetName, checkName, pipelineName string) (*query.Query, error)

func BuildAdhocQueryTag added in v0.11.574

func BuildAdhocQueryTag(annotations string) (string, error)

BuildAdhocQueryTag builds the JSON annotation payload for an adhoc query (e.g. `bruin query`). When annotations is empty, the baseline annotation is still emitted so every adhoc query is tagged.

func BuildAnnotationJSON added in v0.11.522

func BuildAnnotationJSON(ctx context.Context, fields map[string]interface{}) (string, error)

BuildAnnotationJSON builds the annotation JSON string by merging standard fields with any user-provided annotations from the context. Returns empty string if annotations are not enabled.

func BuildTruncateInsertQuery added in v0.11.298

func BuildTruncateInsertQuery(task *pipeline.Asset, query string) (string, error)

BuildTruncateInsertQuery creates a truncate+insert query that works for standard ANSI SQL databases. This can be used by platforms that support standard TRUNCATE TABLE syntax with transactions.

func GetColumnsWithMergeLogic added in v0.11.325

func GetColumnsWithMergeLogic(asset *pipeline.Asset) []pipeline.Column

func LogQueryIfVerbose added in v0.11.326

func LogQueryIfVerbose(ctx context.Context, writer interface{}, queryString string)

LogQueryIfVerbose logs the SQL query to the writer if verbose mode is enabled. It checks for the verbose flag in the context and writes a formatted query preview to the printer writer, truncating queries longer than QueryLogCharacterLimit.

Types

type CheckError added in v0.11.389

type CheckError struct {
	Query    string
	Result   int64
	Expected int64
	Message  string
}

CheckError is a custom error type that carries query and result information for better error reporting when running single checks.

func (*CheckError) Error added in v0.11.389

func (e *CheckError) Error() string

type CheckRunner

type CheckRunner interface {
	Check(ctx context.Context, ti *scheduler.ColumnCheckInstance) error
}

type ColumnCheckOperator

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

func NewColumnCheckOperator

func NewColumnCheckOperator(checks map[string]CheckRunner) *ColumnCheckOperator

func (ColumnCheckOperator) Run

type CountableQueryCheck

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

func NewCountableQueryCheck

func NewCountableQueryCheck(conn config.ConnectionGetter, expectedQueryResult int64, queryInstance *query.Query, checkName string, customError func(count int64) error) *CountableQueryCheck

func (*CountableQueryCheck) Check

func (*CountableQueryCheck) CustomCheck

type CustomCheck

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

func NewCustomCheck

func NewCustomCheck(conn config.ConnectionGetter, renderer jinja.RendererInterface) *CustomCheck

func (*CustomCheck) Check

type CustomCheckOperator

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

func (*CustomCheckOperator) Run

type CustomCheckRunner

type CustomCheckRunner interface {
	Check(ctx context.Context, ti *scheduler.CustomCheckInstance) error
}

type DBColumn added in v0.11.172

type DBColumn struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Nullable    bool   `json:"nullable"`
	PrimaryKey  bool   `json:"primary_key"`
	Unique      bool   `json:"unique"`
	Description string `json:"description,omitempty"` // Column description/comment
}

type DBColumnType added in v0.11.172

type DBColumnType struct {
	Name      string `json:"name"`
	Size      int    `json:"size"`
	Precision int    `json:"precision"`
	Scale     int    `json:"scale"`
}

type DBDatabase added in v0.11.172

type DBDatabase struct {
	Name    string      `json:"name"`
	Schemas []*DBSchema `json:"schemas"`
}

func (*DBDatabase) TableExists added in v0.11.172

func (d *DBDatabase) TableExists(schema, table string) bool

type DBSchema added in v0.11.172

type DBSchema struct {
	Name   string     `json:"name"`
	Tables []*DBTable `json:"tables"`
}

type DBTable added in v0.11.172

type DBTable struct {
	Name           string      `json:"name"`
	Type           DBTableType `json:"type,omitempty"`            // "table" or "view"
	ViewDefinition string      `json:"view_definition,omitempty"` // SQL definition for views
	Columns        []*DBColumn `json:"columns"`

	// Metadata fields for import description enrichment
	CreatedAt    *time.Time `json:"created_at,omitempty"`    // When the table was created
	LastModified *time.Time `json:"last_modified,omitempty"` // When the table was last modified
	RowCount     *int64     `json:"row_count,omitempty"`     // Number of rows in the table
	SizeBytes    *int64     `json:"size_bytes,omitempty"`    // Size of the table in bytes
	Description  string     `json:"description,omitempty"`   // Description from the database
	Owner        string     `json:"owner,omitempty"`         // Owner of the table
	TableComment string     `json:"table_comment,omitempty"` // Comment/description on the table
}

type DBTableType added in v0.11.430

type DBTableType string

DBTableType represents the type of a database table.

const (
	// DBTableTypeTable represents a regular table.
	DBTableTypeTable DBTableType = "table"
	// DBTableTypeView represents a view.
	DBTableTypeView DBTableType = "view"
)

type MaxCheck added in v0.11.280

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

func NewMaxCheck added in v0.11.280

func NewMaxCheck(conn config.ConnectionGetter) *MaxCheck

func (*MaxCheck) Check added in v0.11.280

type MinCheck added in v0.11.280

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

func NewMinCheck added in v0.11.280

func NewMinCheck(conn config.ConnectionGetter) *MinCheck

func (*MinCheck) Check added in v0.11.280

type NegativeCheck added in v0.10.1

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

func NewNegativeCheck added in v0.10.1

func NewNegativeCheck(conn config.ConnectionGetter) *NegativeCheck

func (*NegativeCheck) Check added in v0.10.1

type NonNegativeCheck

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

func NewNonNegativeCheck

func NewNonNegativeCheck(conn config.ConnectionGetter) *NonNegativeCheck

func (*NonNegativeCheck) Check

type NotNullCheck

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

func NewNotNullCheck

func NewNotNullCheck(conn config.ConnectionGetter) *NotNullCheck

func (*NotNullCheck) Check

type PositiveCheck

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

func NewPositiveCheck

func NewPositiveCheck(conn config.ConnectionGetter) *PositiveCheck

func (*PositiveCheck) Check

type QuerySensor added in v0.11.222

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

func NewQuerySensor added in v0.11.222

func NewQuerySensor(conn config.ConnectionGetter, extractor query.QueryExtractor, sensorMode string) *QuerySensor

func (*QuerySensor) Run added in v0.11.222

func (*QuerySensor) RunTask added in v0.11.222

func (o *QuerySensor) RunTask(ctx context.Context, p *pipeline.Pipeline, t *pipeline.Asset) error

type SchemaCreator added in v0.11.175

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

func NewSchemaCreator added in v0.11.175

func NewSchemaCreator() *SchemaCreator

func (*SchemaCreator) CreateSchemaIfNotExist added in v0.11.175

func (sc *SchemaCreator) CreateSchemaIfNotExist(ctx context.Context, qr queryRunner, asset *pipeline.Asset) error

type TableExistsChecker added in v0.11.286

type TableExistsChecker interface {
	Select(ctx context.Context, q *query.Query) ([][]interface{}, error)
	BuildTableExistsQuery(tableName string) (string, error)
}

type TableSensor added in v0.11.286

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

func NewTableSensor added in v0.11.286

func NewTableSensor(conn config.ConnectionGetter, sensorMode string, extractor query.QueryExtractor) *TableSensor

func NewTableSensorWithDependencies added in v0.11.286

func NewTableSensorWithDependencies(
	conn config.ConnectionGetter,
	sensorMode string,
	extractor query.QueryExtractor,
) *TableSensor

func (*TableSensor) Run added in v0.11.286

func (*TableSensor) RunTask added in v0.11.286

func (ts *TableSensor) RunTask(ctx context.Context, p *pipeline.Pipeline, t *pipeline.Asset) error

type TableSummaryResult added in v0.11.224

type TableSummaryResult struct {
	RowCount int64    `json:"row_count"`
	Table    *DBTable `json:"table"`
}

func (*TableSummaryResult) String added in v0.11.224

func (tsr *TableSummaryResult) String() string

type UniqueCheck

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

func NewUniqueCheck

func NewUniqueCheck(conn config.ConnectionGetter) *UniqueCheck

func (*UniqueCheck) Check

Jump to

Keyboard shortcuts

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