devenv

package
v0.11.813 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenameSelfReference added in v0.11.813

func RenameSelfReference(renamer TableRenamer, dialect, assetName, schemaPrefix, sql string) (string, error)

RenameSelfReference points references to an asset's own table at its prefixed name, without connecting to the database. assetName is the already prefixed name, e.g. "dev_mart.events". Only references written exactly as the unprefixed name are renamed, the same rule Modify uses: whether MART.events and mart.events are the same table depends on the dialect and on quoting, which UsedTables does not report. Other tables are left as written, since whether their prefixed copies exist can only be checked on the database.

func UnprefixedName added in v0.11.813

func UnprefixedName(assetName, schemaPrefix string) (string, bool)

UnprefixedName returns the name an asset had before its schema was prefixed, e.g. "mart.table1" for "dev_mart.table1". It reports false when the name is not a schema.table or catalog.schema.table name with a prefixed schema.

Types

type DevEnvQueryModifier

type DevEnvQueryModifier struct {
	Dialect string
	Conn    config.ConnectionGetter
	Parser  TableRenamer
	// contains filtered or unexported fields
}

func (*DevEnvQueryModifier) Modify

func (*DevEnvQueryModifier) ModifyForConnection added in v0.11.813

func (d *DevEnvQueryModifier) ModifyForConnection(ctx context.Context, schemaPrefix, connName string, conn any, q *query.Query) (*query.Query, error)

ModifyForConnection rewrites a query that does not belong to an asset, such as an ad-hoc `bruin query`, the same way Modify does: each schema.table reference is pointed at the prefixed schema when that table exists there.

func (*DevEnvQueryModifier) RegisterAssetForSchemaCache

func (d *DevEnvQueryModifier) RegisterAssetForSchemaCache(ctx context.Context, p *pipeline.Pipeline, a *pipeline.Asset, q *query.Query) error

type TableRenamer added in v0.11.813

type TableRenamer interface {
	UsedTables(sql, dialect string) ([]string, error)
	RenameTables(sql, dialect string, tableMapping map[string]string) (string, error)
}

TableRenamer is the part of the SQL parser that dev environments use.

Jump to

Keyboard shortcuts

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