athena

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckInternalAthenaError added in v0.33.2

func CheckInternalAthenaError(_ any, err error) exec.ErrorType

func EscapeString

func EscapeString(value string) string

EscapeString converts a string value to something you can embed in an SQL query (if you can't use parametrized queries). The string is surrounded by single quotes, so you don't need to take care of that yourself.

func IsInternalAthenaError added in v0.33.2

func IsInternalAthenaError(err error) bool

func NewClient

func NewClient(ctx context.Context, config cfg.Config, logger log.Logger, name string, optFns ...ClientOption) (*athena.Client, error)

func NewRepository

func NewRepository[T any](ctx context.Context, config cfg.Config, logger log.Logger, settings *Settings) (*repository[T], error)

func NewRepositoryRaw

func NewRepositoryRaw(ctx context.Context, config cfg.Config, logger log.Logger, settings *Settings) (*repositoryRaw, error)

func NewRepositoryRawWithInterfaces

func NewRepositoryRawWithInterfaces(db *sql.DB, executor exec.Executor, settings *Settings) *repositoryRaw

func NewRepositoryWithInterfaces

func NewRepositoryWithInterfaces[T any](raw RepositoryRaw, settings *Settings) *repository[T]

func ProvideClient

func ProvideClient(ctx context.Context, config cfg.Config, logger log.Logger, name string, optFns ...ClientOption) (*athena.Client, error)

func ReplaceDollarPlaceholders

func ReplaceDollarPlaceholders(query string, args []any) (sql string, err error)

ReplaceDollarPlaceholders replaces $1, $2, etc. with the corresponding element from params. You have to supply an additional escape function which converts each parameter to a string safe to embed in the query.

Types

type ClientConfig

type ClientConfig struct {
	Settings    ClientSettings
	LoadOptions []func(options *awsCfg.LoadOptions) error
}

func (ClientConfig) GetLoadOptions

func (c ClientConfig) GetLoadOptions() []func(options *awsCfg.LoadOptions) error

func (ClientConfig) GetRetryOptions

func (c ClientConfig) GetRetryOptions() []func(*retry.StandardOptions)

func (ClientConfig) GetSettings

func (c ClientConfig) GetSettings() gosoAws.ClientSettings

type ClientOption

type ClientOption func(cfg *ClientConfig)

type ClientSettings

type ClientSettings struct {
	gosoAws.ClientSettings
	Database       string        `cfg:"database"`
	OutputLocation string        `cfg:"output_location"`
	PollFrequency  time.Duration `cfg:"poll_frequency" default:"3s"`
}

type Repository

type Repository[T any] interface {
	RepositoryRaw
	// QueryBuilder returns a prepared query builder with prefilled columns and table name
	QueryBuilder() squirrel.SelectBuilder
	// Query accepts a query builder and executes the resulting sql statement.
	Query(ctx context.Context, qb squirrel.SelectBuilder) ([]T, error)
	// QuerySql accepts an already formatted sql statement and executes it.
	QuerySql(ctx context.Context, query string) ([]T, error)
}

Repository is a high level repository implementation to query Athena. The repository is typed to return a slice of structs as a result instead of raw rows.

type RepositoryRaw

type RepositoryRaw interface {
	// QueryRows accepts a SQL statement and returns the result as *sqlx.Rows
	QueryRows(ctx context.Context, sql string) (*sqlx.Rows, error)
}

RepositoryRaw is a low level repository implementation to query Athena tables.

type Settings

type Settings struct {
	ClientName string
	TableName  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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