Documentation
¶
Index ¶
- Variables
- func LogOrSinkQueryID(ctx context.Context, dbType string, queryID string)
- func LogQueryID(ctx context.Context, dbType string, queryID string)
- func WithQueryIDSink(ctx context.Context, sink *string) context.Context
- type DryRunColumn
- type DryRunResult
- type FileQuerySplitterExtractor
- func (f FileQuerySplitterExtractor) CloneForAsset(ctx context.Context, p *pipeline.Pipeline, t *pipeline.Asset) (QueryExtractor, error)
- func (f FileQuerySplitterExtractor) ExtractQueriesFromString(content string) ([]*Query, error)
- func (f FileQuerySplitterExtractor) ReextractQueriesFromSlice(content []string) ([]string, error)
- type Query
- type QueryDryRunner
- type QueryExtractor
- type QueryResult
- type Renderer
- type WholeFileExtractor
- func (f *WholeFileExtractor) CloneForAsset(ctx context.Context, p *pipeline.Pipeline, t *pipeline.Asset) (QueryExtractor, error)
- func (f *WholeFileExtractor) ExtractQueriesFromString(content string) ([]*Query, error)
- func (f *WholeFileExtractor) ReextractQueriesFromSlice(content []string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultJinjaRenderer = jinja.NewRenderer(jinja.Context{ "ds": time.Now().Format("2006-01-02"), "ds_nodash": time.Now().Format("20060102"), "data_interval_start": time.Now().AddDate(0, 0, -1).Format(time.RFC3339), "data_interval_end": time.Now().Format(time.RFC3339), "utils": map[string]interface{}{ "date_add": func(str string, days int) string { return str }, "date_format": func(str, inputFormat, outputFormat string) string { return str }, }, })
Functions ¶
func LogOrSinkQueryID ¶ added in v0.11.558
LogOrSinkQueryID either writes the query ID to the sink in the context (if one was set via WithQueryIDSink) or logs it to the console.
func LogQueryID ¶ added in v0.11.558
LogQueryID prints a database query ID to the console writer in the context. It is a no-op if the context has no writer or the queryID is empty.
func WithQueryIDSink ¶ added in v0.11.558
WithQueryIDSink returns a context that captures query IDs into the given string pointer instead of logging them. This allows callers (e.g. sensors) to control when and whether to log the ID.
Types ¶
type DryRunColumn ¶ added in v0.11.475
DryRunColumn represents a single column in the output schema of a dry-run result.
type DryRunResult ¶ added in v0.11.475
type DryRunResult struct {
// ConnectionType identifies the database backend (e.g., "bigquery", "snowflake", "postgres").
ConnectionType string `json:"connectionType"`
// Valid indicates whether the query passed validation without errors.
Valid bool `json:"valid"`
// BigQuery-specific fields
TotalBytesProcessed int64 `json:"totalBytesProcessed,omitempty"`
EstimatedCostUSD float64 `json:"estimatedCostUSD,omitempty"`
StatementType string `json:"statementType,omitempty"`
ReferencedTables []string `json:"referencedTables,omitempty"`
Schema []DryRunColumn `json:"schema,omitempty"`
// EXPLAIN-based databases populate this with the query plan output.
ExplainRows *QueryResult `json:"explainRows,omitempty"`
}
DryRunResult holds the output of a dry-run operation. Different databases populate different fields depending on their capabilities.
type FileQuerySplitterExtractor ¶
type FileQuerySplitterExtractor struct {
Fs afero.Fs
Renderer jinja.RendererInterface
}
FileQuerySplitterExtractor is a regular file extractor, but it splits the queries in the given file into multiple instances. For usecases that require EXPLAIN statements, such as validating Snowflake queries, it is not possible to use a single query with multiple statements, so we need to split them into multiple queries.
func (FileQuerySplitterExtractor) CloneForAsset ¶ added in v0.11.230
func (f FileQuerySplitterExtractor) CloneForAsset(ctx context.Context, p *pipeline.Pipeline, t *pipeline.Asset) (QueryExtractor, error)
func (FileQuerySplitterExtractor) ExtractQueriesFromString ¶ added in v0.7.1
func (f FileQuerySplitterExtractor) ExtractQueriesFromString(content string) ([]*Query, error)
func (FileQuerySplitterExtractor) ReextractQueriesFromSlice ¶ added in v0.11.230
func (f FileQuerySplitterExtractor) ReextractQueriesFromSlice(content []string) ([]string, error)
type QueryDryRunner ¶ added in v0.11.475
type QueryDryRunner interface {
DryRunQuery(ctx context.Context, q *Query) (*DryRunResult, error)
}
QueryDryRunner is an optional interface that database connections can implement to support dry-run / explain functionality for the "bruin query --dry-run" command.
type QueryExtractor ¶ added in v0.11.182
type QueryResult ¶ added in v0.11.53
type WholeFileExtractor ¶
type WholeFileExtractor struct {
Fs afero.Fs
Renderer jinja.RendererInterface
}
WholeFileExtractor is a regular file extractor that returns the whole file content as the query string. It is useful for cases where the whole file content can be treated as a single query, such as validating GoogleCloudPlatform queries via dry-run.
func (*WholeFileExtractor) CloneForAsset ¶ added in v0.11.182
func (f *WholeFileExtractor) CloneForAsset(ctx context.Context, p *pipeline.Pipeline, t *pipeline.Asset) (QueryExtractor, error)
func (*WholeFileExtractor) ExtractQueriesFromString ¶ added in v0.7.1
func (f *WholeFileExtractor) ExtractQueriesFromString(content string) ([]*Query, error)
func (*WholeFileExtractor) ReextractQueriesFromSlice ¶ added in v0.11.165
func (f *WholeFileExtractor) ReextractQueriesFromSlice(content []string) ([]string, error)