ansisql

package
v0.11.430 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func AddAgentIDAnnotationComment added in v0.11.397

func AddAgentIDAnnotationComment(q *query.Query, agentID string) *query.Query

AddAgentIDAnnotationComment adds an agent ID annotation comment to the query. This is used for adhoc queries to track which agent executed them. The comment is prepended to the beginning of the query (works for BigQuery and others). For Snowflake, use BuildAgentIDQueryTag with gosnowflake.WithQueryTag instead.

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 BuildAgentIDQueryTag added in v0.11.397

func BuildAgentIDQueryTag(agentID string) string

BuildAgentIDQueryTag builds the JSON query tag string for agent ID annotation. This is used for Snowflake's QUERY_TAG via gosnowflake.WithQueryTag.

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"`
}

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"`
}

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