Documentation
¶
Index ¶
- func BQTypeStringFromToolType(toolType string) (string, error)
- func DryRunQuery(ctx context.Context, restService *bigqueryrestapi.Service, projectID string, ...) (*bigqueryrestapi.Job, error)
- func InitializeDatasetParameters(allowedDatasets []string, defaultProjectID string, ...) (projectParam, datasetParam parameters.Parameter)
- func StripSingleQuotes(s string) string
- func TableParser(sql, defaultProjectID string) ([]string, error)
- func ValidColumnName(s string) bool
- func ValidColumnParam(s string) bool
- func ValidContributionMetricParam(s string) bool
- func ValidTableID(s string) bool
- type MockSource
- func (m *MockSource) BigQueryAllowedDatasets() []string
- func (m *MockSource) BigQueryClient() *bigqueryapi.Client
- func (m *MockSource) BigQuerySession() bigqueryds.BigQuerySessionProvider
- func (m *MockSource) GetAuthTokenHeaderName() string
- func (m *MockSource) GetMaximumBytesBilled() int64
- func (m *MockSource) IsDatasetAllowed(projectID, datasetID string) bool
- func (m *MockSource) RetrieveClientAndService(tools.AccessToken) (*bigqueryapi.Client, *bigqueryrestapi.Service, error)
- func (m *MockSource) RunSQL(ctx context.Context, client *bigqueryapi.Client, sql string, queryType string, ...) (any, error)
- func (m *MockSource) UseClientAuthorization() bool
- type MockSourceProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BQTypeStringFromToolType ¶
BQTypeStringFromToolType converts a tool parameter type string to a BigQuery standard SQL type string.
func DryRunQuery ¶
func DryRunQuery(ctx context.Context, restService *bigqueryrestapi.Service, projectID string, location string, sql string, params []*bigqueryrestapi.QueryParameter, connProps []*bigqueryapi.ConnectionProperty, maximumBytesBilled int64) (*bigqueryrestapi.Job, error)
DryRunQuery performs a dry run of the SQL query to validate it and get metadata.
func InitializeDatasetParameters ¶
func InitializeDatasetParameters( allowedDatasets []string, defaultProjectID string, projectKey, datasetKey string, projectDescription, datasetDescription string, ) (projectParam, datasetParam parameters.Parameter)
InitializeDatasetParameters generates project and dataset tool parameters based on allowedDatasets.
func StripSingleQuotes ¶ added in v1.4.0
StripSingleQuotes removes leading and trailing single quotes from a string if both are present.
func TableParser ¶
TableParser is the main entry point for parsing a SQL string to find all referenced table IDs. It handles multi-statement SQL, comments, and recursive parsing of EXECUTE IMMEDIATE statements.
func ValidColumnName ¶ added in v1.4.0
ValidColumnName returns true if s is a safe BigQuery column name. Values that fail this check must not be interpolated as SQL identifiers or into single-quoted SQL string arguments that represent column references.
func ValidColumnParam ¶ added in v1.4.0
ValidColumnParam returns true if s (stripped of leading/trailing single quotes) is a safe column name.
func ValidContributionMetricParam ¶ added in v1.4.0
ValidContributionMetricParam returns true if s (stripped of leading/trailing single quotes) is a safe contribution metric (does not contain single quotes).
func ValidTableID ¶ added in v1.4.0
ValidTableID returns true if s is a safe BigQuery table identifier of the form 'dataset.table' or 'project.dataset.table'. Values that fail this check must not be interpolated into backtick-quoted SQL.
Types ¶
type MockSource ¶ added in v1.4.0
type MockSource struct {
sources.Source
CalledSQL string
Client *bigqueryapi.Client
AllowedDatasets []string
RunSQLResult any
RunSQLError error
}
MockSource is a reusable mock implementation of sources.Source for BigQuery tool tests.
func (*MockSource) BigQueryAllowedDatasets ¶ added in v1.4.0
func (m *MockSource) BigQueryAllowedDatasets() []string
func (*MockSource) BigQueryClient ¶ added in v1.4.0
func (m *MockSource) BigQueryClient() *bigqueryapi.Client
func (*MockSource) BigQuerySession ¶ added in v1.4.0
func (m *MockSource) BigQuerySession() bigqueryds.BigQuerySessionProvider
func (*MockSource) GetAuthTokenHeaderName ¶ added in v1.4.0
func (m *MockSource) GetAuthTokenHeaderName() string
func (*MockSource) GetMaximumBytesBilled ¶ added in v1.4.0
func (m *MockSource) GetMaximumBytesBilled() int64
func (*MockSource) IsDatasetAllowed ¶ added in v1.4.0
func (m *MockSource) IsDatasetAllowed(projectID, datasetID string) bool
func (*MockSource) RetrieveClientAndService ¶ added in v1.4.0
func (m *MockSource) RetrieveClientAndService(tools.AccessToken) (*bigqueryapi.Client, *bigqueryrestapi.Service, error)
func (*MockSource) RunSQL ¶ added in v1.4.0
func (m *MockSource) RunSQL(ctx context.Context, client *bigqueryapi.Client, sql string, queryType string, params []bigqueryapi.QueryParameter, connProps []*bigqueryapi.ConnectionProperty) (any, error)
func (*MockSource) UseClientAuthorization ¶ added in v1.4.0
func (m *MockSource) UseClientAuthorization() bool
type MockSourceProvider ¶ added in v1.4.0
type MockSourceProvider struct {
tools.SourceProvider
Source sources.Source
}
MockSourceProvider is a reusable mock implementation of tools.SourceProvider.