Documentation ¶
Overview ¶
Package athenadriver is a fully-featured Go database/sql driver for Amazon AWS Athena developed at Uber Technologies Inc.
It provides a hassle-free way of querying AWS Athena database with Go standard library. It not only provides basic features of Athena Go SDK, but addresses some of its limitation, improves and extends it.Except the basic features provided by Go database/sql like error handling, database pool and reconnection, athenadriver supports the following features out of box:
- Support multiple AWS authorization methods
- Full support of Athena Basic Data Types
- Full support of Athena Advanced Type for queries with Geospatial identifiers, ML and UDFs
- Full support of ALL Athena Query Statements, including DDL, DML and UTILITY
- Support newly added INSERT INTO...VALUES
- Full support of Athena Basic Data Types
- Athena workgroup and tagging support including remote workgroup creation
- Go sql's Prepared statement support
- Go sql's DB.Exec() and db.ExecContext() support
- Query cancelling support
- Mask columns with specific values
- Database missing value handling
- Read-Only mode
Amazon Athena is an interactive query service that lets you use standard SQL to analyze data directly in Amazon S3. You can point Athena at your data in Amazon S3 and run ad-hoc queries and get results in seconds. Athena is serverless, so there is no infrastructure to set up or manage. You pay only for the queries you run. Athena scales automatically—executing queries in parallel—so results are fast, even with large datasets and complex queries. Author: Henry Fuheng Wu (wufuheng@gmail.com, henry.wu@uber.com)
Index ¶
- Constants
- Variables
- func ColsRowsToCSV(rows *sql.Rows) string
- func ColsToCSV(rows *sql.Rows) string
- func FormatBytes(v []byte) []byte
- func FormatString(v string) string
- func GetDefaultWGConfig() *athena.WorkGroupConfiguration
- func GetFromEnvVal(keys []string) string
- func GetTableNamesInQuery(query string) map[string]bool
- func GetTidySQL(query string) string
- func IsQID(q string) bool
- func NewWGConfig(bytesScannedCutoffPerQuery int64, enforceWorkGroupConfiguration bool, ...) *athena.WorkGroupConfiguration
- func PrettyPrintCSV(rows *sql.Rows)
- func PrettyPrintFancy(rows *sql.Rows)
- func PrettyPrintMD(rows *sql.Rows)
- func PrettyPrintSQLColsRows(rows *sql.Rows, style string, render string, page int)
- func PrettyPrintSQLRows(rows *sql.Rows, style string, render string, page int)
- func RowsToCSV(rows *sql.Rows) string
- type AthenaCache
- type AthenaResult
- type AthenaTime
- type Config
- func (c *Config) CheckColumnMasked(columnName string) (string, bool)
- func (c *Config) GetAWSProfile() string
- func (c *Config) GetAccessID() string
- func (c *Config) GetDB() string
- func (c *Config) GetOutputBucket() string
- func (c *Config) GetRegion() string
- func (c *Config) GetResultPollIntervalSeconds() time.Duration
- func (c *Config) GetSecretAccessKey() string
- func (c *Config) GetServiceLimitOverride() *ServiceLimitOverride
- func (c *Config) GetSessionToken() string
- func (c *Config) GetUser() string
- func (c *Config) GetWorkgroup() Workgroup
- func (c *Config) IsLoggingEnabled() bool
- func (c *Config) IsMetricsEnabled() bool
- func (c *Config) IsMissingAsDefault() bool
- func (c *Config) IsMissingAsEmptyString() bool
- func (c *Config) IsMissingAsNil() bool
- func (c *Config) IsMoneyWise() bool
- func (c *Config) IsReadOnly() bool
- func (c *Config) IsWGRemoteCreationAllowed() bool
- func (c *Config) SafeStringify() string
- func (c *Config) SetAWSProfile(profile string)
- func (c *Config) SetAccessID(o string) error
- func (c *Config) SetDB(o string)
- func (c *Config) SetLogging(b bool)
- func (c *Config) SetMaskedColumnValue(columnName string, value string)
- func (c *Config) SetMetrics(b bool)
- func (c *Config) SetMissingAsDefault(b bool)
- func (c *Config) SetMissingAsEmptyString(b bool)
- func (c *Config) SetMissingAsNil(b bool)
- func (c *Config) SetMoneyWise(b bool)
- func (c *Config) SetOutputBucket(o string) error
- func (c *Config) SetReadOnly(b bool)
- func (c *Config) SetRegion(o string) error
- func (c *Config) SetResultPollIntervalSeconds(n int)
- func (c *Config) SetSecretAccessKey(o string) error
- func (c *Config) SetServiceLimitOverride(serviceLimitOverride ServiceLimitOverride)
- func (c *Config) SetSessionToken(o string)
- func (c *Config) SetUser(o string)
- func (c *Config) SetWGRemoteCreationAllowed(b bool)
- func (c *Config) SetWorkGroup(w *Workgroup) error
- func (c *Config) String() string
- func (c *Config) Stringify() string
- type Connection
- func (c *Connection) Begin() (driver.Tx, error)
- func (c *Connection) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (c *Connection) CheckNamedValue(nv *driver.NamedValue) (err error)
- func (c *Connection) Close() error
- func (c *Connection) ExecContext(ctx context.Context, query string, namedArgs []driver.NamedValue) (driver.Result, error)
- func (c *Connection) Ping(ctx context.Context) error
- func (c *Connection) Prepare(query string) (driver.Stmt, error)
- func (c *Connection) QueryContext(ctx context.Context, query string, namedArgs []driver.NamedValue) (driver.Rows, error)
- type DriverTracer
- func (c *DriverTracer) Config() *Config
- func (c *DriverTracer) Log(lvl zapcore.Level, msg string, fields ...zap.Field)
- func (c *DriverTracer) Logger() *zap.Logger
- func (c *DriverTracer) Scope() tally.Scope
- func (c *DriverTracer) SetLogger(logger *zap.Logger)
- func (c *DriverTracer) SetScope(scope tally.Scope)
- type QIDMetaData
- type Rows
- type SQLConnector
- type SQLDriver
- type ServiceLimitOverride
- func (c *ServiceLimitOverride) GetAsStringMap() map[string]string
- func (c *ServiceLimitOverride) GetDDLQueryTimeout() int
- func (c *ServiceLimitOverride) GetDMLQueryTimeout() int
- func (c *ServiceLimitOverride) SetDDLQueryTimeout(seconds int) error
- func (c *ServiceLimitOverride) SetDMLQueryTimeout(seconds int) error
- func (c *ServiceLimitOverride) SetFromValues(kvp url.Values)
- type Statement
- type TContextKey
- type WGConfig
- type WGTags
- type Workgroup
Constants ¶
const ( // DriverName is the Name of this DB driver. DriverName = "awsathenaLD" // DefaultBytesScannedCutoffPerQuery is 1G for every user. DefaultBytesScannedCutoffPerQuery = 1024 * 1024 * 1024 // DefaultDBName is the default database name in Athena. DefaultDBName = "default" // DefaultWGName is the default workgroup name in Athena DefaultWGName = "primary" // DefaultRegion is the default region in Athena. DefaultRegion = "us-east-1" // TimestampUniXFormat is from https://docs.aws.amazon.com/athena/latest/ug/data-types.html. // https://stackoverflow.com/questions/20530327/origin-of-mon-jan-2-150405-mst-2006-in-golang // RFC3339 is not supported by AWS Athena. It uses session timezone!. TimestampUniXFormat = "2006-01-02 15:04:05.000" // ZeroDateTimeString is the invalid or zero result for a time.Time ZeroDateTimeString = "0001-01-01 00:00:00 +0000 UTC" // DateUniXFormat comes along the same way as TimestampUniXFormat. DateUniXFormat = "2006-01-02" // MetricsKey is the key for Metrics in context MetricsKey = TContextKey("MetricsKey") // LoggerKey is the key for Logger in context LoggerKey = TContextKey("LoggerKey") // DummyRegion is used when AWS CLI Config is used, ie AWS_SDK_LOAD_CONFIG is set DummyRegion = "dummy" // DummyAccessID is used when AWS CLI Config is used, ie AWS_SDK_LOAD_CONFIG is set DummyAccessID = "dummy" // DummySecretAccessKey is used when AWS CLI Config is used, ie AWS_SDK_LOAD_CONFIG is set DummySecretAccessKey = "dummy" )
const ( // DDLQueryTimeout is DDL query timeout 600 minutes(unit second). DDLQueryTimeout = 600 * 60 // DMLQueryTimeout is DML query timeout 30 minutes(unit second). DMLQueryTimeout = 30 * 60 // PoolInterval is the interval between two status checks(unit second). PoolInterval = 3 // The maximum allowed query string length is 262144 bytes, // where the strings are encoded in UTF-8. // This is not an adjustable quota. (unit bytes) MAXQueryStringLength = 262144 )
https://docs.aws.amazon.com/athena/latest/ug/service-limits.html
const ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = zap.DebugLevel // InfoLevel is the default logging priority. InfoLevel = zap.InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = zap.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. // DPanicLevel, PanicLevel and FatalLevel are not allowed in this package // to avoid terminating the whole process ErrorLevel = zap.ErrorLevel )
const DriverVersion = "1.1.15"
DriverVersion is athenadriver's version
const PCGetDriverVersion = "get_driver_version"
PCGetDriverVersion is the pseudo command to get the version of athenadriver
const PCGetQID = "get_query_id"
PCGetQID is the pseudo command of getting query execution id of an SQL
const PCGetQIDStatus = "get_query_id_status"
PCGetQIDStatus is the pseudo command of getting status of a query execution id
const PCStopQID = "stop_query_id"
PCStopQID is the pseudo command to stop a query execution id
const Version = "0.1.0"
Version of the library.
Variables ¶
var ( ErrInvalidQuery = errors.New("query is not valid") ErrConfigInvalidConfig = errors.New("driver config is invalid") ErrConfigOutputLocation = errors.New("output location must starts with s3") ErrConfigRegion = errors.New("region is required") ErrConfigWGPointer = errors.New("workgroup pointer is nil") ErrConfigAccessIDRequired = errors.New("AWS access ID is required") ErrConfigAccessKeyRequired = errors.New("AWS access Key is required") ErrQueryUnknownType = errors.New("query parameter type is unknown") ErrQueryBufferOF = errors.New("query buffer overflow") ErrQueryTimeout = errors.New("query timeout") ErrAthenaTransactionUnsupported = errors.New("Athena doesn't support transaction statements") ErrAthenaNilDatum = errors.New("*athena.Datum must not be nil") ErrAthenaNilAPI = errors.New("athenaAPI must not be nil") ErrTestMockGeneric = errors.New("some_mock_error_for_test") ErrTestMockFailedByAthena = errors.New("the reason why Athena failed the query") ErrServiceLimitOverride = fmt.Errorf("service limit override must be greater than %d", PoolInterval) )
Various errors the driver might return. Can change between driver versions.
var AthenaColumnTypes = [...]string{"tinyint", "smallint", "integer", "bigint", "float", "real", "double",
"json", "char", "varchar", "varbinary", "row", "string", "binary",
"struct", "interval year to month", "interval day to second", "decimal",
"ipaddress", "array", "map", "unknown", "boolean", "date", "time", "time with time zone",
"timestamp with time zone", "timestamp", "weird_type"}
AthenaColumnTypes is a fixed array of Athena Column Types. An array isn't immutable by nature; you can't make it constant.
var OutputFormats = [...]string{"csv", "html", "markdown", "table"}
OutputFormats are all the formats we can choose to print query result
var OutputStyles = [...]string{"StyleDefault", "StyleBold", "StyleColoredBright", "StyleColoredDark",
"StyleColoredBlackOnBlueWhite", "StyleColoredBlackOnCyanWhite", "StyleColoredBlackOnGreenWhite",
"StyleColoredBlackOnMagentaWhite", "StyleColoredBlackOnYellowWhite", "StyleColoredBlackOnRedWhite",
"StyleColoredBlueWhiteOnBlack", "StyleColoredCyanWhiteOnBlack", "StyleColoredGreenWhiteOnBlack",
"StyleColoredMagentaWhiteOnBlack", "StyleColoredRedWhiteOnBlack", "StyleColoredYellowWhiteOnBlack",
"StyleDouble", "StyleLight", "StyleRounded",
}
OutputStyles are all the styles we can choose to print query result
Functions ¶
func ColsRowsToCSV ¶
ColsRowsToCSV is a convenient function to convert columns and rows of sql.Rows to CSV format.
func FormatBytes ¶
FormatBytes formats a byte slice query argument for Athena by escaping special characters and surrounding it with single quotes.
func FormatString ¶
FormatString formats a string type query argument for Athena by escaping special characters and surrounding the string with single quotes. Using FormatString allows for selective formatting of the query argument, if typecasting or function calls are part of the query argument.
Example usage: query := "SELECT * FROM my_table WHERE description = ? AND created > ?"
args := []any{ aws.String(athenadriver.FormatString("The bunny's eating a carrot")), aws.String(fmt.Sprintf("TIMESTAMP %s", athenadriver.FormatString("2024-07-01 00:00:00"))) }
func GetDefaultWGConfig ¶
func GetDefaultWGConfig() *athena.WorkGroupConfiguration
GetDefaultWGConfig to create a default WorkGroupConfiguration.
func GetFromEnvVal ¶
GetFromEnvVal is to get environmental variable value by keys. The return value is from whichever key is set according to the order in the slice.
func GetTableNamesInQuery ¶
GetTableNamesInQuery is a pessimistic function to return tables involved in query in format of DB.TABLE https://regoio.herokuapp.com/ https://golang.org/pkg/regexp/syntax/
func IsQID ¶
IsQID is to check if a query string is a Query ID the hexadecimal Athena query ID like a44f8e61-4cbb-429a-b7ab-bea2c4a5caed https://aws.amazon.com/premiumsupport/knowledge-center/access-download-athena-query-results/
func NewWGConfig ¶
func NewWGConfig(bytesScannedCutoffPerQuery int64, enforceWorkGroupConfiguration bool, publishCloudWatchMetricsEnabled bool, requesterPaysEnabled bool, resultConfiguration *athena.ResultConfiguration) *athena.WorkGroupConfiguration
NewWGConfig to create a WorkGroupConfiguration.
func PrettyPrintCSV ¶
PrettyPrintCSV is to print rows in CSV format with default style
func PrettyPrintFancy ¶
PrettyPrintFancy is to print rows in table format with fancy style
func PrettyPrintMD ¶
PrettyPrintMD is to print rows in markdown format with default style
func PrettyPrintSQLColsRows ¶
PrettyPrintSQLColsRows is to print rows beautifully with header
func PrettyPrintSQLRows ¶
PrettyPrintSQLRows is to print rows beautifully
Types ¶
type AthenaCache ¶
type AthenaCache interface { // SetQID is to put query -> QIDMetaData into cache SetQID(query string, data QIDMetaData) // GetQID is to get QIDMetaData from cache by query string GetQID(query string) QIDMetaData // GetQuery is to get query string from cache by QID GetQuery(QID string) string }
AthenaCache is for Cached Query
type AthenaResult ¶
type AthenaResult struct {
// contains filtered or unexported fields
}
AthenaResult is the result of an Athena query execution.
func (AthenaResult) LastInsertId ¶
func (a AthenaResult) LastInsertId() (int64, error)
LastInsertId returns the database's auto-generated ID after, for example, an INSERT into a table with primary key. For Athena, it is nil as Athena Go SDK doesn't support it.
func (AthenaResult) RowsAffected ¶
func (a AthenaResult) RowsAffected() (int64, error)
RowsAffected returns the number of rows affected by the query.
type AthenaTime ¶
AthenaTime represents a time.Time value that can be null. The AthenaTime supports Athena's Date, Time and Timestamp data types, with or without time zone.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is for AWS Athena Driver Config. Be noted this is different from aws.Config.
func NewDefaultConfig ¶
func NewDefaultConfig(outputBucket string, region string, accessID string, secretAccessKey string) (*Config, error)
NewDefaultConfig is to new a Config with some default values.
func NewNoOpsConfig ¶
func NewNoOpsConfig() *Config
NewNoOpsConfig is to create a noop version of driver Config WITHOUT credentials.
func (*Config) CheckColumnMasked ¶
CheckColumnMasked is to check if a specific column has been masked by some value. https://stackoverflow.com/questions/30285169/replace-the-empty-or-null-value-with-specific-value-in-hive-query-result/30289503
func (*Config) GetAWSProfile ¶
GetAWSProfile is to get the credential provider name manually set by user
func (*Config) GetAccessID ¶
GetAccessID is a getter of AWS Access ID. It will try to get access ID from:
- string stored in c.values
- environmental variable ${AWS_ACCESS_KEY_ID} or ${AWS_ACCESS_KEY}
func (*Config) GetOutputBucket ¶
GetOutputBucket is getter of OutputBucket.
func (*Config) GetResultPollIntervalSeconds ¶
GetResultPollIntervalSeconds is getter of resultPollIntervalSeconds.
func (*Config) GetSecretAccessKey ¶
GetSecretAccessKey is a getter of AWS Access Key.
func (*Config) GetServiceLimitOverride ¶
func (c *Config) GetServiceLimitOverride() *ServiceLimitOverride
GetServiceLimitOverride is to get the ServiceLimitOverride manually set by a user
func (*Config) GetSessionToken ¶
GetSessionToken is a getter of AWS Session Token.
func (*Config) GetWorkgroup ¶
GetWorkgroup is getter of Workgroup.
func (*Config) IsLoggingEnabled ¶
IsLoggingEnabled is to check if driver level logging enabled.
func (*Config) IsMetricsEnabled ¶
IsMetricsEnabled is to check if driver level metrics enabled.
func (*Config) IsMissingAsDefault ¶
IsMissingAsDefault return true if missing value is set to be returned as default data.
func (*Config) IsMissingAsEmptyString ¶
IsMissingAsEmptyString return true if missing value is set to be returned as empty string.
func (*Config) IsMissingAsNil ¶
IsMissingAsNil return true if missing value is set to be returned as nil.
func (*Config) IsMoneyWise ¶
IsMoneyWise is to check if we are in the moneywise mode
func (*Config) IsReadOnly ¶
IsReadOnly is to check if only SELECT/SHOW/DESC are allowed
func (*Config) IsWGRemoteCreationAllowed ¶
IsWGRemoteCreationAllowed is to check if we are allowed to create workgroup with API from client.
func (*Config) SafeStringify ¶
SafeStringify is a secure version of Stringify(), with security information masked with *.
func (*Config) SetAWSProfile ¶
SetAWSProfile is to manually set the credential provider https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html
func (*Config) SetAccessID ¶
SetAccessID is a setter of AWS Access ID.
func (*Config) SetLogging ¶
SetLogging is to set if driver level logging enabled.
func (*Config) SetMaskedColumnValue ¶
SetMaskedColumnValue is to set masked value for some column.
func (*Config) SetMetrics ¶
SetMetrics is to set if driver level logging enabled.
func (*Config) SetMissingAsDefault ¶
SetMissingAsDefault is to set if missing value is returned as default data.
func (*Config) SetMissingAsEmptyString ¶
SetMissingAsEmptyString is to set if missing value is returned as empty string.
func (*Config) SetMissingAsNil ¶
SetMissingAsNil is to set if missing value is returned as nil.
func (*Config) SetMoneyWise ¶
SetMoneyWise is to set if we are in the moneywise mode
func (*Config) SetOutputBucket ¶
SetOutputBucket is to set S3 bucket for result set. On March 1, 2018, we updated our naming conventions for S3 buckets in the US East (N. Virginia) Region to match the naming conventions that we use in all other worldwide AWS Regions. Amazon S3 no longer supports creating bucket names that contain uppercase letters or underscores. https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules
func (*Config) SetReadOnly ¶
SetReadOnly is to set if only SELECT/SHOW/DESC are allowed
func (*Config) SetResultPollIntervalSeconds ¶
SetResultPollIntervalSeconds is a setter of Overriding poll interval.
func (*Config) SetSecretAccessKey ¶
SetSecretAccessKey is a setter of AWS Access Key.
func (*Config) SetServiceLimitOverride ¶
func (c *Config) SetServiceLimitOverride(serviceLimitOverride ServiceLimitOverride)
SetServiceLimitOverride is to set values from a ServiceLimitOverride
func (*Config) SetSessionToken ¶
SetSessionToken is a setter of AWS Session Token.
func (*Config) SetWGRemoteCreationAllowed ¶
SetWGRemoteCreationAllowed is to set if we are allowed to create workgroup with API from client.
func (*Config) SetWorkGroup ¶
SetWorkGroup is a setter of WorkGroup.
func (*Config) Stringify ¶
Stringify is to return the string form of DSN like JSON.stringify(). Please refer to: https://www.w3schools.com/js/js_json_stringify.asp
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a connection to AWS Athena. It is not used concurrently by multiple goroutines. Connection is assumed to be stateful.
func (*Connection) Begin ¶
func (c *Connection) Begin() (driver.Tx, error)
Begin is from Conn interface, but no implementation for AWS Athena.
func (*Connection) CheckNamedValue ¶
func (c *Connection) CheckNamedValue(nv *driver.NamedValue) (err error)
CheckNamedValue is to implement interface driver.NamedValueChecker.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close is from Conn interface, but no implementation for AWS Athena. Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.
func (*Connection) ExecContext ¶
func (c *Connection) ExecContext(ctx context.Context, query string, namedArgs []driver.NamedValue) (driver.Result, error)
ExecContext executes a query that doesn't return rows, such as an INSERT or UPDATE.
func (*Connection) Ping ¶
func (c *Connection) Ping(ctx context.Context) error
Ping implements driver.Pinger interface. Ping is a good first step in a health check: If the Ping succeeds, make a simple query, then make a complex query which depends on proper DB scheme. This will make troubleshooting simpler as the error now is: "We've got network connectivity, we can Ping the DB, so we have valid credentials for a SELECT xxx; but ...".
func (*Connection) Prepare ¶
func (c *Connection) Prepare(query string) (driver.Stmt, error)
Prepare is inherited from Conn interface.
func (*Connection) QueryContext ¶
func (c *Connection) QueryContext(ctx context.Context, query string, namedArgs []driver.NamedValue) (driver.Rows, error)
QueryContext is implemented to be called by `DB.Query` (QueryerContext interface).
"QueryerContext is an optional interface that may be implemented by a Conn. If a Conn does not implement QueryerContext, the sql package's DB.Query will fall back to Queryer; if the Conn does not implement Queryer either, DB.Query will first prepare a query, execute the statement, and then close the statement."
With QueryContext implemented, we don't need Queryer. QueryerContext must honor the context timeout and return when the context is canceled.
type DriverTracer ¶
type DriverTracer struct {
// contains filtered or unexported fields
}
DriverTracer is supported in athenadriver builtin.
func NewDefaultObservability ¶
func NewDefaultObservability(config *Config) *DriverTracer
NewDefaultObservability is to create an observability object with logger and scope as default(noops object).
func NewNoOpsObservability ¶
func NewNoOpsObservability() *DriverTracer
NewNoOpsObservability is for testing purpose.
func NewObservability ¶
NewObservability is to create an observability object.
func (*DriverTracer) Log ¶
Log is to log with zap.logger with 4 logging levels. We threw away the panic and fatal level as we don't want to DB error terminates the whole process.
func (*DriverTracer) Logger ¶
func (c *DriverTracer) Logger() *zap.Logger
Logger is a getter of logger.
func (*DriverTracer) Scope ¶
func (c *DriverTracer) Scope() tally.Scope
Scope is a getter of tally.Scope.
func (*DriverTracer) SetLogger ¶
func (c *DriverTracer) SetLogger(logger *zap.Logger)
SetLogger is a setter of logger.
func (*DriverTracer) SetScope ¶
func (c *DriverTracer) SetScope(scope tally.Scope)
SetScope is a setter of tally.Scope.
type QIDMetaData ¶
type QIDMetaData struct { QID string // contains filtered or unexported fields }
QIDMetaData is the meta data for QID
type Rows ¶
type Rows struct { ResultOutput *athena.GetQueryResultsOutput // contains filtered or unexported fields }
Rows defines rows in AWS Athena ResultSet.
func NewNonOpsRows ¶
func NewNonOpsRows(ctx context.Context, athenaAPI athenaiface.AthenaAPI, queryID string, driverConfig *Config, obs *DriverTracer) (*Rows, error)
NewNonOpsRows is to create a new Rows.
func NewRows ¶
func NewRows(ctx context.Context, athenaAPI athenaiface.AthenaAPI, queryID string, driverConfig *Config, obs *DriverTracer) (*Rows, error)
NewRows is to create a new Rows.
func (*Rows) ColumnTypeDatabaseTypeName ¶
ColumnTypeDatabaseTypeName will be called by sql framework.
type SQLConnector ¶
type SQLConnector struct {
// contains filtered or unexported fields
}
SQLConnector is the connector for AWS Athena Driver.
func NoopsSQLConnector ¶
func NoopsSQLConnector() *SQLConnector
NoopsSQLConnector is to create a noops SQLConnector.
func (*SQLConnector) Connect ¶
Connect is to create an AWS session. The order to find auth information to create session is: 1. Manually set AWS profile in Config by calling config.SetAWSProfile(profileName) 2. AWS_SDK_LOAD_CONFIG 3. Static Credentials Ref: https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html
func (*SQLConnector) Driver ¶
func (c *SQLConnector) Driver() driver.Driver
Driver is to construct a new SQLConnector.
type SQLDriver ¶
type SQLDriver struct {
// contains filtered or unexported fields
}
SQLDriver is an implementation of sql/driver interface for AWS Athena. https://vyskocilm.github.io/blog/implement-sql-database-driver-in-100-lines-of-go/ https://golang.org/pkg/database/sql/driver/#Driver
func (*SQLDriver) Open ¶
Open returns a new connection to AWS Athena. The dsn is a string in a driver-specific format. the sql package maintains a pool of idle connections for efficient re-use. The returned connection is only used by one goroutine at a time.
func (*SQLDriver) OpenConnector ¶
OpenConnector will be called upon query execution. If a Driver implements DriverContext.OpenConnector, then sql.DB will call OpenConnector to obtain a Connector and then invoke that Connector's Conn method to obtain each needed connection, instead of invoking the Driver's Open method for each connection. The two-step sequence allows drivers to parse the name just once and also provides access to per-Conn contexts.
type ServiceLimitOverride ¶
type ServiceLimitOverride struct {
// contains filtered or unexported fields
}
ServiceLimitOverride allows users to override service limits, hardcoded in constants.go. This assumes the service limits have been raised in the AWS account. https://docs.aws.amazon.com/athena/latest/ug/service-limits.html
func NewServiceLimitOverride ¶
func NewServiceLimitOverride() *ServiceLimitOverride
NewServiceLimitOverride is to create an empty ServiceLimitOverride. Values can be set using setters.
func (*ServiceLimitOverride) GetAsStringMap ¶
func (c *ServiceLimitOverride) GetAsStringMap() map[string]string
GetAsStringMap is to get the ServiceLimitOverride as a map of strings and aids in setting url.Values in Config
func (*ServiceLimitOverride) GetDDLQueryTimeout ¶
func (c *ServiceLimitOverride) GetDDLQueryTimeout() int
GetDDLQueryTimeout is to get the DDLQueryTimeout override.
func (*ServiceLimitOverride) GetDMLQueryTimeout ¶
func (c *ServiceLimitOverride) GetDMLQueryTimeout() int
GetDMLQueryTimeout is to get the DMLQueryTimeout override.
func (*ServiceLimitOverride) SetDDLQueryTimeout ¶
func (c *ServiceLimitOverride) SetDDLQueryTimeout(seconds int) error
SetDDLQueryTimeout is to set the DDLQueryTimeout override.
func (*ServiceLimitOverride) SetDMLQueryTimeout ¶
func (c *ServiceLimitOverride) SetDMLQueryTimeout(seconds int) error
SetDMLQueryTimeout is to set the DMLQueryTimeout override.
func (*ServiceLimitOverride) SetFromValues ¶
func (c *ServiceLimitOverride) SetFromValues(kvp url.Values)
SetFromValues is to set ServiceLimitOverride properties from a url.Values which might be a list of override and other ignored values from a dsn
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
Statement is to implement Go's database/sql Statement.
func (*Statement) ColumnConverter ¶
func (s *Statement) ColumnConverter(idx int) driver.ValueConverter
ColumnConverter is to return driver's DefaultParameterConverter.
type WGConfig ¶
type WGConfig struct {
// contains filtered or unexported fields
}
WGConfig wraps WorkGroupConfiguration.
type WGTags ¶
type WGTags struct {
// contains filtered or unexported fields
}
WGTags is a wrapper of []*athena.Tag.
type Workgroup ¶
type Workgroup struct { Name string Config *athena.WorkGroupConfiguration Tags *WGTags }
Workgroup is a wrapper of Athena Workgroup.
func NewDefaultWG ¶
func NewDefaultWG(name string, config *athena.WorkGroupConfiguration, tags *WGTags) *Workgroup
NewDefaultWG is to create new default Workgroup.
func NewWG ¶
func NewWG(name string, config *athena.WorkGroupConfiguration, tags *WGTags) *Workgroup
NewWG is to create a new Workgroup.
func (*Workgroup) CreateWGRemotely ¶
func (w *Workgroup) CreateWGRemotely(athenaService athenaiface.AthenaAPI) error
CreateWGRemotely is to create a Workgroup remotely.