Documentation
¶
Index ¶
- Constants
- Variables
- func AppendValueToArrowField(field array.Builder, value interface{}, tpe *util.DataType) error
- func ConvertToArrowDataType(tpe *util.DataType) (arrow.DataType, error)
- func ConvertToArrowValue(value interface{}, tpe *util.DataType) (string, error)
- func DSN(cfg *Config) (dsn string)
- func GetDriverFlag(ctx context.Context, key string) (string, bool)
- func GetHttpResponseMsgToJson(headers map[string]string, path string, connection *ClickzettaConn, ...) (*fastjson.Value, []byte, error)
- func Open(dsn string) gorm.Dialector
- func SFCallerPrettyfier(frame *runtime.Frame) (string, string)
- func SetLogger(inLogger *SFLogger)
- func WithDriverFlags(ctx context.Context, flags DriverFlags) context.Context
- type BinaryValues
- type BulkLoadCommitMode
- type BulkLoadConfig
- type BulkLoadOperation
- type BulkLoadState
- type BulkloadCommitOptions
- type BulkloadMetadata
- type BulkloadOptions
- type BulkloadStream
- type BulkloadWriter
- func (bw *BulkloadWriter) Abort() error
- func (bw *BulkloadWriter) CheckFileStatus() error
- func (bw *BulkloadWriter) Close() error
- func (bw *BulkloadWriter) CloseCurrentFile() error
- func (bw *BulkloadWriter) ConstructArrowSchema() error
- func (bw *BulkloadWriter) CreateNextFileWriter() (*pqarrow.FileWriter, error)
- func (bw *BulkloadWriter) CreateRow() *Row
- func (bw *BulkloadWriter) CurrentFileName() string
- func (bw *BulkloadWriter) EstimateRowSize() int
- func (bw *BulkloadWriter) Finish() error
- func (bw *BulkloadWriter) FlushRecordBatch() (int, error)
- func (bw *BulkloadWriter) Init() error
- func (bw *BulkloadWriter) ParsePartitionSpec() (map[string]string, error)
- func (bw *BulkloadWriter) ProcessStagingType() error
- func (bw *BulkloadWriter) UploadLocalFile() (string, error)
- func (bw *BulkloadWriter) WriteRow(row *Row) error
- type CZTable
- type ClickZettaConfig
- type ClickzettaConn
- func (conn *ClickzettaConn) Begin() (driver.Tx, error)
- func (conn *ClickzettaConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (std *ClickzettaConn) CheckNamedValue(nv *driver.NamedValue) error
- func (conn *ClickzettaConn) Close() (err error)
- func (conn *ClickzettaConn) CommitBulkloadStream(streamId string, commitMode BulkLoadCommitMode, option BulkloadOptions) (*BulkloadMetadata, error)
- func (conn *ClickzettaConn) CreateBulkloadStream(option BulkloadOptions) (*BulkloadStream, error)
- func (conn *ClickzettaConn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (conn *ClickzettaConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (conn *ClickzettaConn) FinishBulkloadStreamWriter(streamId string, option BulkloadOptions, partitionId uint32, ...) (*ingestion.ResponseStatus, error)
- func (conn *ClickzettaConn) GateWayCall(message proto.Message, method ingestion.MethodEnum) (*fastjson.Value, error)
- func (conn *ClickzettaConn) GetBulkloadStream(streamId string, option BulkloadOptions) (*BulkloadMetadata, error)
- func (conn *ClickzettaConn) GetDistributeBulkloadStream(streamId string, option BulkloadOptions) (*BulkloadStream, error)
- func (conn *ClickzettaConn) OpenBulkloadStreamWriter(streamId string, option BulkloadOptions, partitionId uint32) (*BulkLoadConfig, error)
- func (conn *ClickzettaConn) Ping(ctx context.Context) error
- func (conn *ClickzettaConn) Prepare(query string) (driver.Stmt, error)
- func (conn *ClickzettaConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (conn *ClickzettaConn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (conn *ClickzettaConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type ClickzettaDriver
- type ClickzettaError
- type ClickzettaResult
- type ClickzettaRows
- type ClickzettaStmt
- func (stmt *ClickzettaStmt) Close() error
- func (stmt *ClickzettaStmt) Exec(args []driver.Value) (driver.Result, error)
- func (stmt *ClickzettaStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (stmt *ClickzettaStmt) NumInput() int
- func (stmt *ClickzettaStmt) Query(args []driver.Value) (driver.Rows, error)
- func (stmt *ClickzettaStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type Config
- type ConfigBool
- type Connector
- type Dialector
- func (dialector Dialector) Apply(config *gorm.Config) error
- func (dialector Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})
- func (dialector *Dialector) Create(db *gorm.DB)
- func (dialector Dialector) DataTypeOf(*schema.Field) string
- func (dialector Dialector) DefaultValueOf(*schema.Field) clause.Expression
- func (dialector Dialector) Explain(sql string, vars ...interface{}) string
- func (dialector Dialector) Initialize(db *gorm.DB) error
- func (dialector Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (dialector Dialector) Name() string
- func (dialector Dialector) NowFunc(n int) func() time.Time
- func (dialector Dialector) QuoteTo(writer clause.Writer, str string)
- type DriverFlags
- type FileFormat
- type InternalClickzettaDriver
- type InternalClient
- type Row
- func (row *Row) SetBigint(columnName string, value interface{}) error
- func (row *Row) SetBoolean(columnName string, value interface{}) error
- func (row *Row) SetDate(columnName string, value interface{}) error
- func (row *Row) SetDecimal(columnName string, value interface{}) error
- func (row *Row) SetDouble(columnName string, value interface{}) error
- func (row *Row) SetFloat(columnName string, value interface{}) error
- func (row *Row) SetInt(columnName string, value interface{}) error
- func (row *Row) SetSmallInt(columnName string, value interface{}) error
- func (row *Row) SetString(columnName string, value interface{}) error
- func (row *Row) SetTimestamp(columnName string, value interface{}) error
- func (row *Row) SetTinyInt(columnName string, value interface{}) error
- type SFLogger
- type StagingConfig
- type TypedNullTime
- type UUID
Constants ¶
const ( SubmitJobRequestPath requestPath = "/lh/submitJob" GetJobResultPath requestPath = "/lh/getJob" CancelJobPath requestPath = "/lh/cancelJob" GetTokenPath requestPath = "/clickzetta-portal/user/loginSingle" GETWAYPATH requestPath = "/igs/gatewayEndpoint" )
const ( // TimestampLTZType denotes a LTZ timezoneType for array binds TimestampLTZType timezoneType = iota // DateType denotes a date type for array binds DateType )
const ( BIGINT clickzettaType = iota BOOLEAN CHAR DATE DECIMAL DOUBLE FLOAT INT INTERVAL SMALLINT STRING TIMESTAMP_LTZ TINYINT ARRAY MAP STRUCT VARCHAR NOT_SUPPORTED JSON )
const ( Memory queryDataType = iota File queryDataType = iota )
const ( OSS objectStorageType = iota COS objectStorageType = iota )
const ( // QueryStatusInProgress denotes a query execution in progress QueryStatusInProgress queryStatus = "queryStatusInProgress" // QueryStatusComplete denotes a completed query execution QueryStatusComplete queryStatus = "queryStatusComplete" // QueryFailed denotes a failed query QueryFailed queryStatus = "queryFailed" )
const ClickzettaGoDriverVersion = "0.0.7"
ClickzettaGoDriverVersion is the version of Go Clickzetta Driver.
const (
DefaultDriverName = "clickzetta"
)
const SFSessionIDKey contextKey = "LOG_SESSION_ID"
SFSessionIDKey is context key of session id
const SFSessionUserKey contextKey = "LOG_USER"
SFSessionUserKey is context key of user id of a session
Variables ¶
var ( SQL_JOB jobType = "SQL_JOB" COMPACTION_JOB jobType = "COMPACTION_JOB" )
var ( UNKNOWN jobRequestMode = "UNKNOWN" HYBRID jobRequestMode = "HYBRID" ASYNC jobRequestMode = "ASYNC" SYNC jobRequestMode = "SYNC" )
var ( // CreateClauses create clauses CreateClauses = []string{"INSERT", "VALUES"} // QueryClauses query clauses QueryClauses = []string{} // UpdateClauses update clauses UpdateClauses = []string{"UPDATE", "SET", "WHERE"} // DeleteClauses delete clauses DeleteClauses = []string{"DELETE", "FROM", "WHERE"} )
var HTTPTransport = &http.Transport{ DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 60 * time.Second, }).DialContext, MaxIdleConns: 500, IdleConnTimeout: 60 * time.Second, ExpectContinueTimeout: 30 * time.Second, MaxIdleConnsPerHost: 100, }
var LogKeys = [...]contextKey{SFSessionIDKey, SFSessionUserKey}
LogKeys these keys in context should be included in logging messages when using logger.WithContext
Functions ¶
func AppendValueToArrowField ¶
func ConvertToArrowDataType ¶
func ConvertToArrowValue ¶
func GetDriverFlag ¶ added in v0.0.11
GetDriverFlag get specified driver flag value from context if flag does not exist, return empty string and false
func SFCallerPrettyfier ¶
SFCallerPrettyfier to provide base file name and function name from calling frame used in SFLogger
func WithDriverFlags ¶ added in v0.0.11
func WithDriverFlags(ctx context.Context, flags DriverFlags) context.Context
WithDriverFlags add driver flags to context example:
ctx := goclickzetta.WithDriverFlags(ctx, goclickzetta.DriverFlags{
"separate_params": "true",
"custom_flag": "value1",
})
db.WithContext(ctx).Raw("SELECT * FROM table").Scan(&results)
Types ¶
type BinaryValues ¶ added in v0.0.10
type BinaryValues struct {
// contains filtered or unexported fields
}
type BulkLoadCommitMode ¶
type BulkLoadCommitMode string
var ( COMMIT_STREAM BulkLoadCommitMode ABORT_STREAM BulkLoadCommitMode )
type BulkLoadConfig ¶
type BulkLoadConfig struct {
BLConfig *ingestion.BulkLoadStreamWriterConfig
}
func (*BulkLoadConfig) GetBulkLoadConfig ¶
func (bc *BulkLoadConfig) GetBulkLoadConfig() (StagingConfig, error)
func (*BulkLoadConfig) GetFileFormat ¶
func (bc *BulkLoadConfig) GetFileFormat() FileFormat
func (*BulkLoadConfig) GetMaxBytesPerFile ¶
func (bc *BulkLoadConfig) GetMaxBytesPerFile() int64
func (*BulkLoadConfig) GetMaxRowsPerFile ¶
func (bc *BulkLoadConfig) GetMaxRowsPerFile() int64
type BulkLoadOperation ¶
type BulkLoadOperation string
var ( APPEND BulkLoadOperation = "APPEND" UPSERT BulkLoadOperation = "UPSERT" OVERWRITE BulkLoadOperation = "OVERWRITE" )
type BulkLoadState ¶
type BulkLoadState string
var ( CREATED BulkLoadState = "CREATED" SEALED BulkLoadState = "SEALED" COMMIT_SUBMITTED BulkLoadState = "COMMIT_SUBMITTED" COMMIT_SUCCESS BulkLoadState = "COMMIT_SUCCESS" COMMIT_FAILED BulkLoadState = "COMMIT_FAILED" ABORTED BulkLoadState = "ABORTED" )
type BulkloadCommitOptions ¶
type BulkloadMetadata ¶
type BulkloadMetadata struct {
InstanceId int64
StreamInfo *ingestion.BulkLoadStreamInfo
Table CZTable
}
func (*BulkloadMetadata) GetOperation ¶
func (bm *BulkloadMetadata) GetOperation() BulkLoadOperation
func (*BulkloadMetadata) GetPartitionSpec ¶
func (bm *BulkloadMetadata) GetPartitionSpec() string
func (*BulkloadMetadata) GetRecordKeys ¶
func (bm *BulkloadMetadata) GetRecordKeys() []string
func (*BulkloadMetadata) GetSQLErrorMsg ¶
func (bm *BulkloadMetadata) GetSQLErrorMsg() string
func (*BulkloadMetadata) GetState ¶
func (bm *BulkloadMetadata) GetState() BulkLoadState
type BulkloadOptions ¶
type BulkloadOptions struct {
Table string
Operation BulkLoadOperation
PartitionSpec string
RecordKeys []string
}
type BulkloadStream ¶
type BulkloadStream struct {
MetaData *BulkloadMetadata
Connection *ClickzettaConn
CommitOptions *BulkloadCommitOptions
StreamOptions *BulkloadOptions
Closed bool
}
func (*BulkloadStream) Abort ¶
func (stream *BulkloadStream) Abort() error
func (*BulkloadStream) Close ¶
func (stream *BulkloadStream) Close() error
func (*BulkloadStream) Commit ¶
func (stream *BulkloadStream) Commit() error
func (*BulkloadStream) GetStreamId ¶
func (stream *BulkloadStream) GetStreamId() string
func (*BulkloadStream) OpenWriter ¶
func (stream *BulkloadStream) OpenWriter(partitionId int64) (*BulkloadWriter, error)
type BulkloadWriter ¶
type BulkloadWriter struct {
Connection *ClickzettaConn
MetaData *BulkloadMetadata
BLConfig *BulkLoadConfig
PartitionId int64
StreamOptions *BulkloadOptions
StageConfig *StagingConfig
PartitionSpec map[string]string
FileSystem fs.FS
FinishedFiles []string
FinishedFileSizes []int
FileNameUUID string
FileId int
Closed bool
CurrentTotalRows int
CurrentTotalBytes int
CurrentRecordBatch map[string][]interface{}
CurrentRecordBatchSize int
CurrentRecordBatchRows int
EstimateRowStaticSize int
ArrowSchema *arrow.Schema
Writer *pqarrow.FileWriter
OSSBucket *oss.Bucket
COSClient *cos.Client
LocalLocation string
}
func (*BulkloadWriter) Abort ¶
func (bw *BulkloadWriter) Abort() error
func (*BulkloadWriter) CheckFileStatus ¶
func (bw *BulkloadWriter) CheckFileStatus() error
func (*BulkloadWriter) Close ¶
func (bw *BulkloadWriter) Close() error
func (*BulkloadWriter) CloseCurrentFile ¶
func (bw *BulkloadWriter) CloseCurrentFile() error
func (*BulkloadWriter) ConstructArrowSchema ¶
func (bw *BulkloadWriter) ConstructArrowSchema() error
func (*BulkloadWriter) CreateNextFileWriter ¶
func (bw *BulkloadWriter) CreateNextFileWriter() (*pqarrow.FileWriter, error)
func (*BulkloadWriter) CreateRow ¶
func (bw *BulkloadWriter) CreateRow() *Row
func (*BulkloadWriter) CurrentFileName ¶
func (bw *BulkloadWriter) CurrentFileName() string
func (*BulkloadWriter) EstimateRowSize ¶
func (bw *BulkloadWriter) EstimateRowSize() int
func (*BulkloadWriter) Finish ¶
func (bw *BulkloadWriter) Finish() error
func (*BulkloadWriter) FlushRecordBatch ¶
func (bw *BulkloadWriter) FlushRecordBatch() (int, error)
func (*BulkloadWriter) Init ¶
func (bw *BulkloadWriter) Init() error
func (*BulkloadWriter) ParsePartitionSpec ¶
func (bw *BulkloadWriter) ParsePartitionSpec() (map[string]string, error)
func (*BulkloadWriter) ProcessStagingType ¶
func (bw *BulkloadWriter) ProcessStagingType() error
func (*BulkloadWriter) UploadLocalFile ¶
func (bw *BulkloadWriter) UploadLocalFile() (string, error)
func (*BulkloadWriter) WriteRow ¶
func (bw *BulkloadWriter) WriteRow(row *Row) error
type ClickZettaConfig ¶ added in v0.0.6
type ClickZettaConfig struct {
DriverName string
DSN string
Conn gorm.ConnPool
SkipInitializeWithVersion bool
DefaultStringSize uint
DefaultDatetimePrecision *int
DisableWithReturning bool
DisableDatetimePrecision bool
DontSupportRenameIndex bool
DontSupportRenameColumn bool
DontSupportNullAsDefaultValue bool
DontSupportRenameColumnUnique bool
DontSupportDropConstraint bool
}
type ClickzettaConn ¶
type ClickzettaConn struct {
// contains filtered or unexported fields
}
func (*ClickzettaConn) CheckNamedValue ¶ added in v0.0.8
func (std *ClickzettaConn) CheckNamedValue(nv *driver.NamedValue) error
func (*ClickzettaConn) Close ¶
func (conn *ClickzettaConn) Close() (err error)
func (*ClickzettaConn) CommitBulkloadStream ¶
func (conn *ClickzettaConn) CommitBulkloadStream(streamId string, commitMode BulkLoadCommitMode, option BulkloadOptions) (*BulkloadMetadata, error)
func (*ClickzettaConn) CreateBulkloadStream ¶
func (conn *ClickzettaConn) CreateBulkloadStream(option BulkloadOptions) (*BulkloadStream, error)
func (*ClickzettaConn) ExecContext ¶
func (conn *ClickzettaConn) ExecContext( ctx context.Context, query string, args []driver.NamedValue) ( driver.Result, error)
func (*ClickzettaConn) FinishBulkloadStreamWriter ¶
func (conn *ClickzettaConn) FinishBulkloadStreamWriter(streamId string, option BulkloadOptions, partitionId uint32, writtenFileList []string, writtenLengths []uint64) (*ingestion.ResponseStatus, error)
func (*ClickzettaConn) GateWayCall ¶
func (conn *ClickzettaConn) GateWayCall(message proto.Message, method ingestion.MethodEnum) (*fastjson.Value, error)
func (*ClickzettaConn) GetBulkloadStream ¶
func (conn *ClickzettaConn) GetBulkloadStream(streamId string, option BulkloadOptions) (*BulkloadMetadata, error)
func (*ClickzettaConn) GetDistributeBulkloadStream ¶
func (conn *ClickzettaConn) GetDistributeBulkloadStream(streamId string, option BulkloadOptions) (*BulkloadStream, error)
func (*ClickzettaConn) OpenBulkloadStreamWriter ¶
func (conn *ClickzettaConn) OpenBulkloadStreamWriter(streamId string, option BulkloadOptions, partitionId uint32) (*BulkLoadConfig, error)
func (*ClickzettaConn) Prepare ¶
func (conn *ClickzettaConn) Prepare(query string) (driver.Stmt, error)
func (*ClickzettaConn) PrepareContext ¶
func (*ClickzettaConn) QueryContext ¶
func (conn *ClickzettaConn) QueryContext( ctx context.Context, query string, args []driver.NamedValue) ( driver.Rows, error)
type ClickzettaDriver ¶
type ClickzettaDriver struct{}
ClickzettaDriver is a context of Go Driver
func (ClickzettaDriver) Open ¶
func (d ClickzettaDriver) Open(dsn string) (driver.Conn, error)
Open creates a new connection.
func (ClickzettaDriver) OpenWithConfig ¶
OpenWithConfig creates a new connection with the given Config.
type ClickzettaError ¶
type ClickzettaError struct {
Number int
SQLState string
QueryID string
Message string
MessageArgs []interface{}
IncludeQueryID bool // TODO: populate this in connection
}
func (*ClickzettaError) Error ¶
func (ce *ClickzettaError) Error() string
type ClickzettaResult ¶
ClickzettaResult provides an API for methods exposed to the clients
type ClickzettaRows ¶
type ClickzettaStmt ¶
type ClickzettaStmt struct {
// contains filtered or unexported fields
}
func (*ClickzettaStmt) Close ¶
func (stmt *ClickzettaStmt) Close() error
func (*ClickzettaStmt) ExecContext ¶
func (stmt *ClickzettaStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
func (*ClickzettaStmt) NumInput ¶
func (stmt *ClickzettaStmt) NumInput() int
func (*ClickzettaStmt) QueryContext ¶
func (stmt *ClickzettaStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
type Config ¶
type Config struct {
UserName string // Username
Password string // Password (requires User)
Schema string // Schema
Workspace string // Workspace
VirtualCluster string // VirtualCluster
Service string // Service
Instance string // Instance
Protocol string // Protocol
Token string
InstanceId int64
Params map[string]*string // other connection parameters
}
Config is a set of configuration parameters
type ConfigBool ¶
type ConfigBool uint8
ConfigBool is a type to represent true or false in the Config
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector creates Driver with the specified Config
func NewConnector ¶
func NewConnector(driver InternalClickzettaDriver, config Config) Connector
NewConnector creates a new connector with the given ClickzettaDriver and Config.
type Dialector ¶ added in v0.0.6
type Dialector struct {
*ClickZettaConfig
}
func (Dialector) DataTypeOf ¶ added in v0.0.6
DataTypeOf implements gorm.Dialector.
func (Dialector) DefaultValueOf ¶ added in v0.0.6
func (dialector Dialector) DefaultValueOf(*schema.Field) clause.Expression
DefaultValueOf implements gorm.Dialector.
func (Dialector) Initialize ¶ added in v0.0.6
type DriverFlags ¶ added in v0.0.11
DriverFlags used to pass driver parameters in context
func GetDriverFlags ¶ added in v0.0.11
func GetDriverFlags(ctx context.Context) DriverFlags
GetDriverFlags get driver flags from context if there are no flags in context, return nil
type FileFormat ¶
type FileFormat string
var ( TEXT FileFormat = "text" PARQUET FileFormat = "parquet" ORC FileFormat = "orc" AVRO FileFormat = "avro" CSV FileFormat = "csv" ARROW FileFormat = "arrow" HIVE_RESULT FileFormat = "hive_result" DUMMY FileFormat = "dummy" MEMORY FileFormat = "memory" ICEBERG FileFormat = "iceberg" )
type InternalClickzettaDriver ¶
type InternalClickzettaDriver interface {
Open(dsn string) (driver.Conn, error)
OpenWithConfig(ctx context.Context, config Config) (driver.Conn, error)
}
InternalClickzettaDriver is the interface for an internal Clickzetta driver
type InternalClient ¶
type InternalClient interface {
Get(context.Context, *url.URL, map[string]string, time.Duration) (*http.Response, error)
Post(context.Context, *url.URL, map[string]string, []byte, time.Duration) (*http.Response, error)
Close() error
}
InternalClient is implemented by HTTPClient
type Row ¶
type Row struct {
Columns map[string]*util.DataType
TableName string
ColumnNameValues map[string]interface{}
}
func (*Row) SetBoolean ¶
func (*Row) SetDecimal ¶
func (*Row) SetSmallInt ¶
func (*Row) SetTimestamp ¶
func (*Row) SetTinyInt ¶
type SFLogger ¶
type SFLogger interface {
rlog.Ext1FieldLogger
SetLogLevel(level string) error
WithContext(ctx context.Context) *rlog.Entry
SetOutput(output io.Writer)
}
func CreateDefaultLogger ¶
func CreateDefaultLogger() SFLogger
CreateDefaultLogger return a new instance of SFLogger with default config