Documentation
¶
Index ¶
- Constants
- Variables
- func Array(v interface{}) driver.Valuer
- func DBCallerPrettyfier(frame *runtime.Frame) (string, string)
- func Date(t time.Time) driver.Valuer
- func Decimal128(v interface{}, s int32) driver.Valuer
- func Decimal32(v interface{}, s int32) driver.Valuer
- func Decimal64(v interface{}, s int32) driver.Valuer
- func DeregisterTLSConfig(key string)
- func IP(i net.IP) driver.Valuer
- func Map(v interface{}) driver.Valuer
- func RegisterTLSConfig(key string, config *tls.Config) error
- func SetLogger(inLogger *DBLogger)
- func Tuple(v interface{}) driver.Valuer
- func UInt64(u uint64) driver.Valuer
- type APIClient
- func (c *APIClient) DoQuery(ctx context.Context, query string, args []driver.Value) (*QueryResponse, error)
- func (c *APIClient) DoRequest(method, path string, headers http.Header, req interface{}, resp interface{}) error
- func (c *APIClient) QueryPage(queryId, path string) (*QueryResponse, error)
- func (c *APIClient) QuerySync(ctx context.Context, query string, args []driver.Value, ...) error
- func (c *APIClient) UploadToStageByPresignURL(stage, fileName string) error
- type Config
- type DBLogger
- type DataField
- type DataParser
- type DataParserOptions
- type DataSchema
- type DatabendConn
- func (dc *DatabendConn) Begin() (driver.Tx, error)
- func (dc *DatabendConn) Close() error
- func (dc *DatabendConn) Commit() (err error)
- func (dc *DatabendConn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (dc *DatabendConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (dc *DatabendConn) Prepare(query string) (driver.Stmt, error)
- func (dc *DatabendConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (dc *DatabendConn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (dc *DatabendConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (dc *DatabendConn) Rollback() error
- type DatabendDriver
- type Error
- type QueryError
- type QueryProgress
- type QueryRequest
- type QueryResponse
- type QueryStats
- type TypeDesc
- type TypeDetail
Constants ¶
const ( DatabendTenantHeader = "X-DATABEND-TENANT" DatabendWarehouseHeader = "X-DATABEND-WAREHOUSE" Authorization = "Authorization" )
const DBSessionIDKey contextKey = "LOG_SESSION_ID"
DBSessionIDKey is context key of session id
const SFSessionUserKey contextKey = "LOG_USER"
SFSessionUserKey is context key of user id of a session
Variables ¶
var ( ErrPlaceholderCount = errors.New("databend: wrong placeholder count") ErrNoLastInsertID = errors.New("no LastInsertId available") ErrNoRowsAffected = errors.New("no RowsAffected available") )
var LogKeys = [...]contextKey{DBSessionIDKey, SFSessionUserKey}
LogKeys these keys in context should be included in logging messages when using logger.WithContext
Functions ¶
func Array ¶
Array wraps slice or array into driver.Valuer interface to allow pass through it from database/sql
func DBCallerPrettyfier ¶
DBCallerPrettyfier to provide base file name and function name from calling frame used in SFLogger
func Decimal128 ¶
Decimal128 converts value to Decimal128 of precision S. The value can be a number or a string. The S (scale) parameter specifies the number of decimal places.
func Decimal32 ¶
Decimal32 converts value to Decimal32 of precision S. The value can be a number or a string. The S (scale) parameter specifies the number of decimal places.
func Decimal64 ¶
Decimal64 converts value to Decimal64 of precision S. The value can be a number or a string. The S (scale) parameter specifies the number of decimal places.
func DeregisterTLSConfig ¶
func DeregisterTLSConfig(key string)
DeregisterTLSConfig removes the tls.Config associated with key.
func RegisterTLSConfig ¶
RegisterTLSConfig registers a custom tls.Config to be used with sql.Open.
func SetLogger ¶
func SetLogger(inLogger *DBLogger)
SetLogger set a new logger of SFLogger interface for godatabend
Types ¶
type APIClient ¶
type APIClient struct {
ApiEndpoint string
Host string
User string
Password string
Tenant string
Warehouse string
PresignedURLDisabled bool
}
func (*APIClient) QueryPage ¶
func (c *APIClient) QueryPage(queryId, path string) (*QueryResponse, error)
func (*APIClient) UploadToStageByPresignURL ¶ added in v0.0.4
type Config ¶
type Config struct {
Tenant string // Tenant
Warehouse string // Warehouse
User string // Username
Password string // Password (requires User)
Database string // Database name
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
Scheme string
Host string
Timeout time.Duration
IdleTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
Location *time.Location
Debug bool
UseDBLocation bool
GzipCompression bool
Params map[string]string
TLSConfig string
PresignedURLDisabled bool
}
Config is a set of configuration parameters
type DBLogger ¶
type DBLogger interface {
rlog.Ext1FieldLogger
SetLogLevel(level string) error
WithContext(ctx context.Context) *rlog.Entry
SetOutput(output io.Writer)
}
DBLogger Databend logger interface to expose FieldLogger defined in logrus
func CreateDefaultLogger ¶
func CreateDefaultLogger() DBLogger
CreateDefaultLogger return a new instance of SFLogger with default config
type DataField ¶
type DataField struct {
Name string `json:"name"`
DataType TypeDetail `json:"data_type"`
}
type DataParser ¶
DataParser implements parsing of a driver value and reporting its type.
func NewDataParser ¶
func NewDataParser(t *TypeDesc, opt *DataParserOptions) (DataParser, error)
NewDataParser creates a new DataParser based on the given TypeDesc.
type DataParserOptions ¶
type DataParserOptions struct {
// Location describes default location for DateTime and Date field without Timezone argument.
Location *time.Location
// UseDBLocation if false: always use Location, ignore DateTime argument.
UseDBLocation bool
}
DataParserOptions describes DataParser options. Ex.: Fields Location and UseDBLocation specify timezone options.
type DataSchema ¶
type DataSchema struct {
Fields []DataField `json:"fields"`
}
type DatabendConn ¶
type DatabendConn struct {
SQLState string
// contains filtered or unexported fields
}
func (*DatabendConn) Close ¶
func (dc *DatabendConn) Close() error
Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.
func (*DatabendConn) Commit ¶
func (dc *DatabendConn) Commit() (err error)
Commit applies prepared statement if it exists
func (*DatabendConn) ExecContext ¶ added in v0.0.9
func (dc *DatabendConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
func (*DatabendConn) PrepareContext ¶
func (*DatabendConn) QueryContext ¶ added in v0.0.9
func (dc *DatabendConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
func (*DatabendConn) Rollback ¶
func (dc *DatabendConn) Rollback() error
Rollback cleans prepared statement
type DatabendDriver ¶
type DatabendDriver struct {
// contains filtered or unexported fields
}
DatabendDriver is a context of Go Driver
func (DatabendDriver) Open ¶
func (d DatabendDriver) Open(dsn string) (driver.Conn, error)
Open creates a new connection.
func (DatabendDriver) OpenWithConfig ¶
OpenWithConfig creates a new connection with the given Config.
type QueryError ¶
type QueryProgress ¶
type QueryRequest ¶
type QueryRequest struct {
SQL string `json:"sql"`
}
type QueryResponse ¶
type QueryResponse struct {
Data [][]interface{} `json:"data"`
Error *QueryError `json:"error"`
FinalURI string `json:"final_uri"`
Id string `json:"id"`
NextURI string `json:"next_uri"`
Schema DataSchema `json:"schema,omitempty"`
State string `json:"state"`
Stats QueryStats `json:"stats"`
StatsURI string `json:"stats_uri"`
}
type QueryStats ¶
type QueryStats struct {
RunningTimeMS float64 `json:"running_time_ms"`
ScanProgress QueryProgress `json:"scan_progress"`
}
type TypeDesc ¶
TypeDesc describes a (possibly nested) data type returned by Databend.
func ParseTypeDesc ¶
ParseTypeDesc parses the type description that ClickHouse provides.
The grammar is quite simple:
desc
name
name()
name(args)
args
desc
desc, args
Examples:
String Nullable(Nothing) Array(Tuple(Tuple(String, String), Tuple(String, UInt64)))
type TypeDetail ¶
type TypeDetail struct {
Type string `json:"type"`
}
