Documentation
¶
Index ¶
- Constants
- Variables
- func NamedValueToValue(args []driver.NamedValue) []driver.Value
- func NewPairResultChan() chan *PairResult
- func RegisterDial(net string, dial DialFunc)
- func SplitWith(data string, sep rune) []string
- func VerifySuccess(status *rpc.TStatus, withInfo bool) error
- func WithLock(lock *sync.Mutex, f func())
- type Config
- type DialFunc
- type HiveConn
- func (conn *HiveConn) Begin() (driver.Tx, error)deprecated
- func (conn *HiveConn) Close() error
- func (conn *HiveConn) Exec(query string, args []driver.Value) (driver.Result, error)deprecated
- func (conn *HiveConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (conn *HiveConn) Ping(ctx context.Context) error
- func (conn *HiveConn) Prepare(query string) (driver.Stmt, error)
- func (conn *HiveConn) Query(query string, args []driver.Value) (driver.Rows, error)deprecated
- func (conn *HiveConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type HiveDriver
- type HiveResult
- type HiveRows
- type HiveStatement
- func (stmt *HiveStatement) CheckNamedValue(value *driver.NamedValue) error
- func (stmt *HiveStatement) Close() error
- func (stmt *HiveStatement) Exec(args []driver.Value) (driver.Result, error)deprecated
- func (stmt *HiveStatement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (stmt *HiveStatement) NumInput() int
- func (stmt *HiveStatement) Query(args []driver.Value) (rows driver.Rows, _ error)deprecated
- func (stmt *HiveStatement) QueryContext(ctx context.Context, args []driver.NamedValue) (rows driver.Rows, _ error)
- type PairResult
Constants ¶
const ( // HiveAuthNoSasl indicate no sasl need here HiveAuthNoSasl = "nosasl" // HiveAuthPlain is the default sasl mechanism HiveAuthPlain = "plain" // HiveAuthKerberos indicate kerberos sasl mechanism need here HiveAuthKerberos = "kerberos" )
const ( DEFAULT_HOST = "locahost" DEFAULT_PORT = 10000 HIVE_2 = "hive2" PARAM_DIAL_TIMEOUT = "dialTimeout" PARAM_EXEC_TIMEOUT = "execTimeout" PARAM_AUTH = "auth" PARAM_KERBEROS_NAME = "kerberos_name" PARAM_RUN_ASYNC = "runAsync" )
const ( AUTH_LDAP = "ldap" AUTH_KERBEROS = "kerberos" )
const (
HIVE_DRIVER_NAME = "hive"
)
Variables ¶
var ( DefaultTimeout = 30 * int64(math.Pow10(9)) ERROR_INVALID_SCHEME = errors.New("Hive: Invalid scheme, only hive2 supported") ERROR_INVALID_CONNECTION_STRING = errors.New("Hive: Invalid connection string") ERROR_INVALID_PORT = errors.New("Hive: Invalid port in connection string") ERROR_INVALID_DATABASE_NAME = errors.New("Hive: Invalid database name") ERROR_INVALID_AUTH_TYPE = errors.New("Hive: Invalid auth type") ERROR_INVALID_DIAL_TIMEOUT = errors.New("Hive: Invalid DialTimeout") ERROR_INVALID_EXEC_TIMEOUT = errors.New("Hive: Invalid ExecTimeout") ERROR_INVALID_ASYNC_VALUE = errors.New("Hive: Invalid async value, must be true or false") )
var ( ERROR_NOT_SUPPORTED = fmt.Errorf("Hive: Not supported") ERROR_NOT_IMPLEMENTED = fmt.Errorf("Hive: Not implemented") ERROR_PREPARED_QUERY_NOT_FOUND = fmt.Errorf("Hive: Prepared query not found") ERROR_INTERNAL = fmt.Errorf("Hive: Internal error") )
var REFLECT_MAP = map[string]reflect.Type{ "BOOLEAN": reflect.TypeOf(true), "TINYINT": reflect.TypeOf(int8(0)), "SMALLINT": reflect.TypeOf(int16(0)), "INT": reflect.TypeOf(int(0)), "BIGINT": reflect.TypeOf(int64(0)), "FLOAT": reflect.TypeOf(float32(0)), "DOUBLE": reflect.TypeOf(float64(0)), "STRING": reflect.TypeOf(string("")), "TIMESTAMP": reflect.TypeOf(int(0)), "BINARY": reflect.TypeOf([]byte{}), "ARRAY": reflect.TypeOf([]interface{}{}), "MAP": reflect.TypeOf(map[string]interface{}{}), "STRUCT": reflect.TypeOf(map[string]interface{}{}), "UNIONTYPE": nil, "DECIMAL": reflect.TypeOf(int(0)), "NULL": reflect.TypeOf(nil), "DATE": reflect.TypeOf(time.Time{}), "VARCHAR": reflect.TypeOf(string("")), "CHAR": reflect.TypeOf(rune(' ')), "INTERVAL_YEAR_MONTH": reflect.TypeOf(time.Time{}), "INTERVAL_DAY_TIME": reflect.TypeOf(time.Time{}), }
REFLECT_MAP is type map from hive to golang
Functions ¶
func NamedValueToValue ¶
func NamedValueToValue(args []driver.NamedValue) []driver.Value
NamedValueToValue parse NamedValue into Value
func NewPairResultChan ¶
func NewPairResultChan() chan *PairResult
NewPairResultChan make a new chan for PairResult
func RegisterDial ¶
RegisterDial registers a custom dial function. It can then be used by the network address mynet(addr), where mynet is the registered new network. addr is passed as a parameter to the dial function.
func VerifySuccess ¶
VerifySuccess verifies if the status is success
Types ¶
type Config ¶
type DialFunc ¶
DialFunc is a function which can be used to establish the network connection. Custom dial functions must be registered with RegisterDial
type HiveConn ¶
type HiveConn struct { Config *Config Transport thrift.TTransport Client *rpc.TCLIServiceClient SessionHandle *rpc.TSessionHandle OperationHandle *rpc.TOperationHandle // contains filtered or unexported fields }
HiveConn implements driver.Conn
func NewHiveConn ¶
NewHiveConn build a new driver.Conn with the given dsn
func (*HiveConn) Close ¶
Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.
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 (*HiveConn) Exec
deprecated
Exec is an optional interface that may be implemented by a Conn.
If a Conn does not implement Execer, the sql package's DB.Exec will first prepare a query, execute the statement, and then close the statement.
Exec may return ErrSkip.
Deprecated: Drivers should implement ExecerContext instead (or additionally).
func (*HiveConn) ExecContext ¶
func (conn *HiveConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext is an optional interface that may be implemented by a Conn.
If a Conn does not implement ExecerContext, the sql package's DB.Exec will first prepare a query, execute the statement, and then close the statement.
ExecerContext may return ErrSkip.
ExecerContext must honor the context timeout and return when the context is canceled.
func (*HiveConn) Ping ¶
Ping is an optional interface that may be implemented by a Conn.
If a Conn does not implement Pinger, the sql package's DB.Ping and DB.PingContext will check if there is at least one Conn available.
If Conn.Ping returns ErrBadConn, DB.Ping and DB.PingContext will remove the Conn from pool.
func (*HiveConn) Query
deprecated
Query is an optional interface that may be implemented by a Conn.
If a Conn does not implement Queryer, the sql package's DB.Query will first prepare a query, execute the statement, and then close the statement.
Query may return ErrSkip.
Deprecated: Drivers should implement QueryerContext instead (or additionally).
func (*HiveConn) QueryContext ¶
func (conn *HiveConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
QueryContext 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 first prepare a query, execute the statement, and then close the statement.
QueryerContext may return ErrSkip.
QueryerContext must honor the context timeout and return when the context is canceled.
type HiveResult ¶
type HiveResult struct {
// contains filtered or unexported fields
}
HiveResult is the result of a query execution.
func (*HiveResult) LastInsertId ¶
func (r *HiveResult) LastInsertId() (int64, error)
LastInsertId returns the database's auto-generated ID after, for example, an INSERT into a table with primary key.
func (*HiveResult) RowsAffected ¶
func (r *HiveResult) RowsAffected() (int64, error)
RowsAffected returns the number of rows affected by the query.
type HiveRows ¶
type HiveRows struct {
// contains filtered or unexported fields
}
HiveRows is an iterator over an executed query's results.
func (*HiveRows) ColumnTypeDatabaseTypeName ¶
ColumnTypeDatabaseTypeName may be implemented by Rows. It should return the database system type name without the length. Type names should be uppercase. Examples of returned types: "VARCHAR", "NVARCHAR", "VARCHAR2", "CHAR", "TEXT", "DECIMAL", "SMALLINT", "INT", "BIGINT", "BOOL", "[]BIGINT", "JSONB", "XML", "TIMESTAMP".
func (*HiveRows) ColumnTypeScanType ¶
ColumnTypeScanType may be implemented by Rows. It should return the value type that can be used to scan types into. For example, the database column type "bigint" this should return "reflect.TypeOf(int64(0))".
func (*HiveRows) Columns ¶
Columns returns the names of the columns. The number of columns of the result is inferred from the length of the slice. If a particular column name isn't known, an empty string should be returned for that entry.
func (*HiveRows) GetQueryLog ¶
GetQueryLog returns the logs generated when query running
type HiveStatement ¶
type HiveStatement struct {
// contains filtered or unexported fields
}
HiveStatement is a prepared statement. It is bound to a Conn and not used by multiple goroutines concurrently.
func NewHiveStatement ¶
func NewHiveStatement(conn *HiveConn, query string) (*HiveStatement, error)
NewHiveStatement create a new driver.stmt with the given conn
func (*HiveStatement) CheckNamedValue ¶
func (stmt *HiveStatement) CheckNamedValue(value *driver.NamedValue) error
CheckNamedValue is called before passing arguments to the driver and is called in place of any ColumnConverter. CheckNamedValue must do type validation and conversion as appropriate for the driver.
func (*HiveStatement) Close ¶
func (stmt *HiveStatement) Close() error
Close closes the statement.
As of Go 1.1, a Stmt will not be closed if it's in use by any queries.
func (*HiveStatement) ExecContext ¶
func (stmt *HiveStatement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
ExecContext executes a query that doesn't return rows, such as an INSERT or UPDATE.
ExecContext must honor the context timeout and return when it is canceled.
func (*HiveStatement) NumInput ¶
func (stmt *HiveStatement) NumInput() int
NumInput returns the number of placeholder parameters.
If NumInput returns >= 0, the sql package will sanity check argument counts from callers and return errors to the caller before the statement's Exec or Query methods are called.
NumInput may also return -1, if the driver doesn't know its number of placeholders. In that case, the sql package will not sanity check Exec or Query argument counts.
func (*HiveStatement) QueryContext ¶
func (stmt *HiveStatement) QueryContext(ctx context.Context, args []driver.NamedValue) (rows driver.Rows, _ error)
QueryContext executes a query that may return rows, such as a SELECT.
QueryContext must honor the context timeout and return when it is canceled.
type PairResult ¶
type PairResult struct {
// contains filtered or unexported fields
}
PairResult represents common func result