goclickzetta

package module
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

README

Go Clickzetta Driver

This topic provides instructions for installing, running, and modifying the Go Clickzetta Driver. The driver supports Go's database/sql package.

Prerequisites

The following software packages are required to use the Go Clickzetta Driver.

Go

The latest driver requires the Go language 1.19 or higher. The supported operating systems are Linux, Mac OS, and Windows, but you may run the driver on other platforms if the Go language works correctly on those platforms.

Installation

Get goclickzetta source code, if not installed.

go get -u github.com/clickzetta/goclickzetta

Development

The developer notes are hosted with the source code on GitHub.

Example code

  • The following example code demonstrates how to use the Go Clickzetta Driver to connect to a Clickzetta account and run a simple query.

import (
"database/sql"
"fmt"
_ "github.com/clickzetta/goclickzetta"
)

type CountResult struct {
    Count int64
}

db, err := sql.Open("clickzetta", "${username}:${pwd}@${protocol}(${service}/${schema}?virtualCluster=${vc}&workspace=${workspace}&instance=${instanceName}")
if err != nil {
    t.Error(err)
}

res, err := db.Query("select count(1) from table;")
if err != nil {
    t.Error(err)
}

for res.Next() {
    var result CountResult
    err := res.Scan(&result.Count)
    if err != nil {
        t.Error(err)
    }
    fmt.Printf("result is: %v", result)
}



  • The following example code demonstrates how to use the Go Clickzetta connection to write batch data to a Clickzetta table.
dsn := "${username}:${pwd}@${protocol}(${service}/${schema}?virtualCluster=${vc}&workspace=${workspace}&instance=${instanceName}"
conn, err := connect(dsn)
if err != nil {
t.Error(err)
}
options := BulkloadOptions{
Table:     "table",
Operation: APPEND,
}
stream, err := conn.CreateBulkloadStream(options)
writer, err := stream.OpenWriter(0)
row := writer.CreateRow()
row.SetBigint("id", int64(1))

row.SetString("month", "January")

row.SetBigint("amount", int64(2))

row.SetDecimal("cost", decimal.NewFromFloat(1.1))

writer.WriteRow(row)

writer.Close()
stream.Close()

More examples can be found in the examples.

DSN (Data Source Name)

The Data Source Name has a common format, like the following:

${username}:${pwd}@${protocol}(${service}/${schema}?virtualCluster=${vc}&workspace=${workspace}&instance=${instanceName}
  • username: The username of the Clickzetta account.
  • pwd: The password of the Clickzetta account.
  • protocol: The protocol of the Clickzetta service. The default value is https.(http,tcp ...)
  • service: The Clickzetta service name.
  • schema: The Clickzetta schema name.
  • vc: The Clickzetta virtual cluster name.
  • workspace: The Clickzetta workspace name.
  • instanceName: The Clickzetta instance name.
Optional Parameters

Additional parameters can be appended to the DSN as query string key-value pairs and are stored in Config.Params. Currently supported optional parameters:

  • separate_params: When set to true, INSERT statements will send parameter bindings as Arrow IPC binary data instead of interpolating them into the SQL string. This is recommended for bulk INSERT operations as it avoids SQL injection risks and improves performance. Default value is false.

Example DSN with separate_params:

${username}:${pwd}@${protocol}(${service}/${schema}?virtualCluster=${vc}&workspace=${workspace}&instance=${instanceName}&separate_params=true

When User use the Clickzetta driver to execute SQL and write batch data , must construct the DSN.

BulkLoad

Users can use BulkLoad to write data to Clickzetta.BulkLoad has three modes: APPEND, OVERWRITE, and UPSERT. The default mode is APPEND.

  • APPEND: The APPEND mode appends data to the table.
  • OVERWRITE: The OVERWRITE mode overwrites the table. If the table has data, the data is deleted.
  • UPSERT: The UPSERT mode updates the table. Users must specify the primary key when using this mode. If the primary key exists, the data is updated. If the primary key does not exist, the data is inserted.

Row

Users can use Row to write data to Clickzetta. Row has the following methods:

  • SetBigint: Sets the value of a int64 column.
  • SetBoolean: Sets the value of a boolean column.
  • SetDate: Sets the value of a date column. (value should be string. eg: "2023-01-01")
  • SetDecimal: Sets the value of a decimal.Decimal column.
  • SetDouble: Sets the value of a float64 column.
  • SetFloat: Sets the value of a float32 column.
  • SetInt: Sets the value of an int32 column.
  • SetSmallint: Sets the value of a int16 column.
  • SetString: Sets the value of a string column.
  • SetTimestamp: Sets the value of a timestamp column. (value should be string. eg: "2023-01-01 00:00:00")
  • SetTinyInt: Sets the value of an int8 column.

Support

For official support, contact Clickzetta support at: https://www.yunqi.tech.

Documentation

Index

Constants

View Source
const (
	SubmitJobRequestPath requestPath = "/lh/submitJob"
	GetJobResultPath     requestPath = "/lh/getJob"
	CancelJobPath        requestPath = "/lh/cancelJob"
	GetTokenPath         requestPath = "/clickzetta-portal/user/loginSingle"
	GETWAYPATH           requestPath = "/igs/gatewayEndpoint"
)
View Source
const (
	// TimestampLTZType denotes a LTZ timezoneType for array binds
	TimestampLTZType timezoneType = iota
	// DateType denotes a date type for array binds
	DateType
)
View Source
const (
	BIGINT clickzettaType = iota
	BOOLEAN
	CHAR
	DATE
	DECIMAL
	DOUBLE
	FLOAT
	INT
	INTERVAL
	SMALLINT
	STRING
	TIMESTAMP_LTZ
	TIMESTAMP_NTZ
	TINYINT
	ARRAY
	MAP
	STRUCT
	VARCHAR
	NOT_SUPPORTED
	JSON
	VECTOR
	VECTOR_TYPE
)
View Source
const (
	Memory queryDataType = iota
	File   queryDataType = iota
)
View Source
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"
)
View Source
const ClickzettaGoDriverVersion = "0.0.7"

ClickzettaGoDriverVersion is the version of Go Clickzetta Driver.

View Source
const (
	DefaultDriverName = "clickzetta"
)
View Source
const SFSessionIDKey contextKey = "LOG_SESSION_ID"

SFSessionIDKey is context key of session id

View Source
const SFSessionUserKey contextKey = "LOG_USER"

SFSessionUserKey is context key of user id of a session

Variables

View Source
var (
	SQL_JOB        jobType = "SQL_JOB"
	COMPACTION_JOB jobType = "COMPACTION_JOB"
)
View Source
var (
	UNKNOWN jobRequestMode = "UNKNOWN"
	HYBRID  jobRequestMode = "HYBRID"
	ASYNC   jobRequestMode = "ASYNC"
	SYNC    jobRequestMode = "SYNC"
)
View Source
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"}
)
View Source
var HTTPTransport = newHTTPTransport()

HTTPTransport is the default transport configuration. Deprecated: kept for backward compatibility. Each connection now creates its own transport.

View Source
var LogKeys = [...]contextKey{SFSessionIDKey, SFSessionUserKey}

LogKeys these keys in context should be included in logging messages when using logger.WithContext

Functions

func AppendValueToArrowField

func AppendValueToArrowField(field array.Builder, value interface{}, tpe *util.DataType) error

AppendValueToArrowField appends a value to an Arrow array builder.

func ConvertToArrowDataType

func ConvertToArrowDataType(tpe *util.DataType) (arrow.DataType, error)

ConvertToArrowDataType converts a protobuf DataType to an Arrow DataType.

func ConvertToArrowValue

func ConvertToArrowValue(value interface{}, tpe *util.DataType) (string, error)

ConvertToArrowValue converts a Go value to its string representation for Arrow.

func DSN

func DSN(cfg *Config) (dsn string)

DSN constructs a DSN for Clickzetta db.

func GetDriverFlag added in v0.0.11

func GetDriverFlag(ctx context.Context, key string) (string, bool)

GetDriverFlag get specified driver flag value from context if flag does not exist, return empty string and false

func GetHttpResponseMsgToJson

func GetHttpResponseMsgToJson(headers map[string]string, path string, connection *ClickzettaConn, jsonData []byte) (*fastjson.Value, []byte, error)

func NewSession added in v0.0.15

func NewSession(db *gorm.DB, flags DriverFlags) *gorm.DB

NewSession returns a new *gorm.DB with the given DriverFlags bound to its context. All subsequent operations on the returned db will automatically use these flags, without needing to call WithDriverFlags on each query.

Example:

wsDB := goclickzetta.NewSession(db, goclickzetta.DriverFlags{
    "workspace": "my_workspace",
    "schema":    "my_schema",
})
wsDB.Find(&results)  // automatically uses my_workspace

func Open added in v0.0.6

func Open(dsn string) gorm.Dialector

func SFCallerPrettyfier

func SFCallerPrettyfier(frame *runtime.Frame) (string, string)

SFCallerPrettyfier to provide base file name and function name from calling frame used in SFLogger

func SetLogger

func SetLogger(inLogger *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 BulkLoadCommittable added in v0.0.16

type BulkLoadCommittable struct {
	StreamId    string
	PartitionId int
	Files       []string // local file paths
	DstFiles    []string // volume file paths (set after PUT)
}

BulkLoadCommittable holds the local file list produced by a writer.

type BulkLoadOperation

type BulkLoadOperation = string

BulkLoadOperation defines the operation type for bulkload.

var (
	APPEND    BulkLoadOperation = "APPEND"
	UPSERT    BulkLoadOperation = "UPSERT"
	OVERWRITE BulkLoadOperation = "OVERWRITE"
)

type BulkLoadState

type BulkLoadState = string

BulkLoadState defines the state of a bulkload stream.

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 BulkloadCommitOptions struct {
	Workspace      string
	VirtualCluster string
}

BulkloadCommitOptions holds commit-related options.

type BulkloadCommitter added in v0.0.16

type BulkloadCommitter struct {
	Connection    *ClickzettaConn
	MetaData      *BulkloadMetadata
	StreamOptions *BulkloadOptions
}

BulkloadCommitter handles the V2 commit lifecycle via SQL.

func (*BulkloadCommitter) Commit added in v0.0.16

func (c *BulkloadCommitter) Commit(committables []BulkLoadCommittable) error

Commit prepares (PUT) and commits (COPY/MERGE) the data.

func (*BulkloadCommitter) PrepareCommit added in v0.0.16

func (c *BulkloadCommitter) PrepareCommit(committables []BulkLoadCommittable) error

PrepareCommit uploads local files to table volume via PUT SQL + presigned URL.

type BulkloadMetadata

type BulkloadMetadata struct {
	InstanceId int64
	StreamInfo *ingestion.BulkLoadStreamInfo
	Table      CZTable
}

BulkloadMetadata holds stream metadata.

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
	PartialUpdateColumns   []string // optional: columns to update in UPSERT mode, empty means update all
	PreferInternalEndpoint bool
	Properties             map[string]string // optional: extra SQL set properties for COPY/MERGE
	LoadUri                string            // optional: local directory for temp parquet files, defaults to os.TempDir()
	MaxRowsPerFile         int               // optional: max rows per parquet file, defaults to 1M
	MaxBytesPerFile        int               // optional: max bytes per parquet file, defaults to 64MB
}

BulkloadOptions holds options for creating a bulkload stream.

type BulkloadStream

type BulkloadStream struct {
	MetaData      *BulkloadMetadata
	Connection    *ClickzettaConn
	CommitOptions *BulkloadCommitOptions
	StreamOptions *BulkloadOptions
	Closed        bool
	// contains filtered or unexported fields
}

BulkloadStream represents a bulkload stream with writer and committer support.

func (*BulkloadStream) Abort

func (stream *BulkloadStream) Abort() error

Abort aborts the stream.

func (*BulkloadStream) Close

func (stream *BulkloadStream) Close() error

Close closes all writers, collects committables, and commits the stream.

func (*BulkloadStream) CreateCommitter added in v0.0.16

func (stream *BulkloadStream) CreateCommitter() *BulkloadCommitter

CreateCommitter creates a committer for this stream.

func (*BulkloadStream) CreateWriter added in v0.0.16

func (stream *BulkloadStream) CreateWriter(partitionId int) (*BulkloadWriter, error)

CreateWriter creates a writer for the given partition.

func (*BulkloadStream) GetStreamId

func (stream *BulkloadStream) GetStreamId() string

func (*BulkloadStream) OpenWriter

func (stream *BulkloadStream) OpenWriter(partitionId int64) (*BulkloadWriter, error)

OpenWriter is an alias for CreateWriter for backward compatibility.

type BulkloadWriter

type BulkloadWriter struct {
	Connection    *ClickzettaConn
	MetaData      *BulkloadMetadata
	PartitionId   int64
	StreamOptions *BulkloadOptions

	FinishedFiles       []string // local file paths (cleared after upload)
	UploadedVolumePaths []string // remote volume paths (accumulated)
	TxnId               string   // transaction id for PUT subdirectory
	FileNameUUID        string
	FileId              int
	Closed              bool
	LocalBaseDir        string
	CurrentTotalRows    int
	CurrentTotalBytes   int

	CurrentRecordBatch     map[string][]interface{}
	CurrentRecordBatchSize int
	CurrentRecordBatchRows int
	EstimateRowStaticSize  int
	ArrowSchema            *arrow.Schema
	Writer                 *pqarrow.FileWriter
	PartitionSpec          map[string]string

	// Configurable thresholds (0 means use defaults)
	MaxRowsPerFile  int
	MaxBytesPerFile int
	BatchFlushSize  int
	BatchFlushRows  int
	// contains filtered or unexported fields
}

BulkloadWriter writes data to local parquet files. Files are uploaded to table volume asynchronously on file roll to minimize local disk usage without blocking row writes.

func (*BulkloadWriter) Abort

func (bw *BulkloadWriter) Abort() error

func (*BulkloadWriter) CheckFileStatus

func (bw *BulkloadWriter) CheckFileStatus() error

func (*BulkloadWriter) CleanupAllVolume added in v0.0.16

func (bw *BulkloadWriter) CleanupAllVolume()

CleanupAllVolume removes all uploaded volume files. Called on abort or commit failure.

func (*BulkloadWriter) Close

func (bw *BulkloadWriter) Close() error

Close flushes remaining data, waits for all async uploads to finish, and cleans up.

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) FlushRecordBatch

func (bw *BulkloadWriter) FlushRecordBatch() (int, error)

func (*BulkloadWriter) GetCommittables added in v0.0.16

func (bw *BulkloadWriter) GetCommittables() []BulkLoadCommittable

GetCommittables returns the committable with already-uploaded volume paths.

func (*BulkloadWriter) Init

func (bw *BulkloadWriter) Init() error

func (*BulkloadWriter) ParsePartitionSpec

func (bw *BulkloadWriter) ParsePartitionSpec() (map[string]string, error)

func (*BulkloadWriter) WriteRow

func (bw *BulkloadWriter) WriteRow(row *Row) error

type CZTable

type CZTable struct {
	SchemaName string
	TableName  string
	TableMeta  *ingestion.StreamSchema
	Schema     map[string]*util.DataType
}

CZTable holds table metadata.

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
	DontSupportForShareClause     bool
	DontSupportNullAsDefaultValue bool
	DontSupportRenameColumnUnique bool
	DontSupportDropConstraint     bool
}

type ClickzettaConn

type ClickzettaConn struct {
	// contains filtered or unexported fields
}

func (*ClickzettaConn) Begin

func (conn *ClickzettaConn) Begin() (driver.Tx, error)

func (*ClickzettaConn) BeginTx

func (conn *ClickzettaConn) BeginTx(
	ctx context.Context,
	opts driver.TxOptions) (
	driver.Tx, error)

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) CreateBulkloadStream

func (conn *ClickzettaConn) CreateBulkloadStream(option BulkloadOptions) (*BulkloadStream, error)

func (*ClickzettaConn) Exec

func (conn *ClickzettaConn) Exec(
	query string,
	args []driver.Value) (
	driver.Result, error)

func (*ClickzettaConn) ExecContext

func (conn *ClickzettaConn) ExecContext(
	ctx context.Context,
	query string,
	args []driver.NamedValue) (
	driver.Result, error)

func (*ClickzettaConn) GateWayCall

func (conn *ClickzettaConn) GateWayCall(message proto.Message, method ingestion.MethodEnum) (*fastjson.Value, error)

func (*ClickzettaConn) GetCatalog added in v0.0.13

func (conn *ClickzettaConn) GetCatalog() string

GetCatalog returns the current catalog of the connection

func (*ClickzettaConn) GetSchema added in v0.0.13

func (conn *ClickzettaConn) GetSchema() string

GetSchema returns the current schema of the connection

func (*ClickzettaConn) Ping

func (conn *ClickzettaConn) Ping(ctx context.Context) error

func (*ClickzettaConn) Prepare

func (conn *ClickzettaConn) Prepare(query string) (driver.Stmt, error)

func (*ClickzettaConn) PrepareContext

func (conn *ClickzettaConn) PrepareContext(
	ctx context.Context,
	query string) (
	driver.Stmt, error)

func (*ClickzettaConn) Query

func (conn *ClickzettaConn) Query(
	query string,
	args []driver.Value) (
	driver.Rows, error)

func (*ClickzettaConn) QueryArrowStream added in v0.0.12

func (conn *ClickzettaConn) QueryArrowStream(ctx context.Context, query string, args []driver.NamedValue) (array.RecordReader, error)

func (*ClickzettaConn) QueryContext

func (conn *ClickzettaConn) QueryContext(
	ctx context.Context,
	query string,
	args []driver.NamedValue) (
	driver.Rows, error)

func (*ClickzettaConn) SetCatalog added in v0.0.13

func (conn *ClickzettaConn) SetCatalog(catalog string)

SetCatalog sets the current catalog for the connection

func (*ClickzettaConn) SetSchema added in v0.0.13

func (conn *ClickzettaConn) SetSchema(schema string)

SetSchema sets the current schema for the connection

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

func (d ClickzettaDriver) OpenWithConfig(ctx context.Context, config Config) (driver.Conn, error)

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

type ClickzettaResult interface {
	GetQueryID() string
	GetStatus() queryStatus
	GetError() error
}

ClickzettaResult provides an API for methods exposed to the clients

type ClickzettaRows

type ClickzettaRows interface {
	GetQueryID() string
	GetStatus() queryStatus
	GetResultRows() ([]interface{}, error)
}

type ClickzettaStmt

type ClickzettaStmt struct {
	// contains filtered or unexported fields
}

func (*ClickzettaStmt) Close

func (stmt *ClickzettaStmt) Close() error

func (*ClickzettaStmt) Exec

func (stmt *ClickzettaStmt) Exec(args []driver.Value) (driver.Result, 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) Query

func (stmt *ClickzettaStmt) Query(args []driver.Value) (driver.Rows, error)

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

func ParseDSN

func ParseDSN(dsn string) (cfg *Config, err error)

ParseDSN parses the DSN string to a Config.

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.

func (Connector) Connect

func (t Connector) Connect(ctx context.Context) (driver.Conn, error)

Connect creates a new connection.

func (Connector) Driver

func (t Connector) Driver() driver.Driver

Driver creates a new driver.

type Dialector added in v0.0.6

type Dialector struct {
	*ClickZettaConfig
}

func (Dialector) Apply added in v0.0.6

func (dialector Dialector) Apply(config *gorm.Config) error

func (Dialector) BindVarTo added in v0.0.6

func (dialector Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})

func (*Dialector) Create added in v0.0.8

func (dialector *Dialector) Create(db *gorm.DB)

func (Dialector) DataTypeOf added in v0.0.6

func (dialector Dialector) DataTypeOf(*schema.Field) string

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) Explain added in v0.0.6

func (dialector Dialector) Explain(sql string, vars ...interface{}) string

func (Dialector) Initialize added in v0.0.6

func (dialector Dialector) Initialize(db *gorm.DB) error

func (Dialector) Migrator added in v0.0.6

func (dialector Dialector) Migrator(db *gorm.DB) gorm.Migrator

Migrator implements gorm.Dialector.

func (Dialector) Name added in v0.0.6

func (dialector Dialector) Name() string

func (Dialector) NowFunc added in v0.0.6

func (dialector Dialector) NowFunc(n int) func() time.Time

func (Dialector) QuoteTo added in v0.0.6

func (dialector Dialector) QuoteTo(writer clause.Writer, str string)

type DriverFlags added in v0.0.11

type DriverFlags map[string]string

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 EmptyRecordReader added in v0.0.13

type EmptyRecordReader struct {
	// contains filtered or unexported fields
}

EmptyRecordReader is a RecordReader that returns no records Used when query returns empty result set

func NewEmptyRecordReader added in v0.0.13

func NewEmptyRecordReader(schema *arrow.Schema) *EmptyRecordReader

NewEmptyRecordReader creates a new empty record reader with the given schema

func NewEmptyRecordReaderFromFields added in v0.0.13

func NewEmptyRecordReaderFromFields(fields []execResponseColumnType) *EmptyRecordReader

NewEmptyRecordReaderFromFields creates a new empty record reader from schema fields

func (*EmptyRecordReader) Err added in v0.0.13

func (r *EmptyRecordReader) Err() error

func (*EmptyRecordReader) Next added in v0.0.13

func (r *EmptyRecordReader) Next() bool

func (*EmptyRecordReader) Record added in v0.0.13

func (r *EmptyRecordReader) Record() arrow.Record

func (*EmptyRecordReader) RecordBatch added in v0.0.13

func (r *EmptyRecordReader) RecordBatch() arrow.Record

func (*EmptyRecordReader) Release added in v0.0.13

func (r *EmptyRecordReader) Release()

func (*EmptyRecordReader) Retain added in v0.0.13

func (r *EmptyRecordReader) Retain()

func (*EmptyRecordReader) Schema added in v0.0.13

func (r *EmptyRecordReader) Schema() *arrow.Schema

type FileFormat

type FileFormat string

FileFormat represents the output file format.

var (
	PARQUET   FileFormat = "parquet"
	ORC       FileFormat = "orc"
	AVRO      FileFormat = "avro"
	CSV       FileFormat = "csv"
	ARROW_FMT FileFormat = "arrow"
)

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 LazyMemoryReader added in v0.0.12

type LazyMemoryReader struct {
	// contains filtered or unexported fields
}

LazyMemoryReader lazily reads base64 encoded arrow data Only decodes the next chunk when the current one is exhausted

func NewLazyMemoryReader added in v0.0.12

func NewLazyMemoryReader(dataChunks []string) (*LazyMemoryReader, error)

NewLazyMemoryReader creates a new lazy memory reader from base64 encoded data chunks

func (*LazyMemoryReader) Err added in v0.0.12

func (r *LazyMemoryReader) Err() error

func (*LazyMemoryReader) Next added in v0.0.12

func (r *LazyMemoryReader) Next() bool

func (*LazyMemoryReader) Record added in v0.0.12

func (r *LazyMemoryReader) Record() arrow.Record

func (*LazyMemoryReader) RecordBatch added in v0.0.13

func (r *LazyMemoryReader) RecordBatch() arrow.Record

func (*LazyMemoryReader) Release added in v0.0.12

func (r *LazyMemoryReader) Release()

func (*LazyMemoryReader) Retain added in v0.0.12

func (r *LazyMemoryReader) Retain()

func (*LazyMemoryReader) Schema added in v0.0.12

func (r *LazyMemoryReader) Schema() *arrow.Schema

type LazyStreamingReader added in v0.0.12

type LazyStreamingReader struct {
	// contains filtered or unexported fields
}

LazyStreamingReader lazily downloads and reads files from presigned URLs Only downloads the next file when the current one is exhausted

func NewLazyStreamingReader added in v0.0.12

func NewLazyStreamingReader(urls []string) (*LazyStreamingReader, error)

NewLazyStreamingReader creates a new lazy streaming reader from presigned URLs

func (*LazyStreamingReader) Err added in v0.0.12

func (r *LazyStreamingReader) Err() error

func (*LazyStreamingReader) Next added in v0.0.12

func (r *LazyStreamingReader) Next() bool

func (*LazyStreamingReader) Record added in v0.0.12

func (r *LazyStreamingReader) Record() arrow.Record

func (*LazyStreamingReader) RecordBatch added in v0.0.13

func (r *LazyStreamingReader) RecordBatch() arrow.Record

func (*LazyStreamingReader) Release added in v0.0.12

func (r *LazyStreamingReader) Release()

func (*LazyStreamingReader) Retain added in v0.0.12

func (r *LazyStreamingReader) Retain()

func (*LazyStreamingReader) Schema added in v0.0.12

func (r *LazyStreamingReader) Schema() *arrow.Schema

type Row

type Row struct {
	Columns          map[string]*util.DataType
	TableName        string
	ColumnNameValues map[string]interface{}
}

Row represents a single row of data to write.

func (*Row) SetBigint

func (row *Row) SetBigint(columnName string, value interface{}) error

func (*Row) SetBoolean

func (row *Row) SetBoolean(columnName string, value interface{}) error

func (*Row) SetDate

func (row *Row) SetDate(columnName string, value interface{}) error

func (*Row) SetDecimal

func (row *Row) SetDecimal(columnName string, value interface{}) error

func (*Row) SetDouble

func (row *Row) SetDouble(columnName string, value interface{}) error

func (*Row) SetFloat

func (row *Row) SetFloat(columnName string, value interface{}) error

func (*Row) SetInt

func (row *Row) SetInt(columnName string, value interface{}) error

func (*Row) SetSmallInt

func (row *Row) SetSmallInt(columnName string, value interface{}) error

func (*Row) SetString

func (row *Row) SetString(columnName string, value interface{}) error

func (*Row) SetTimestamp

func (row *Row) SetTimestamp(columnName string, value interface{}) error

func (*Row) SetTinyInt

func (row *Row) SetTinyInt(columnName string, value interface{}) error

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

func GetLogger

func GetLogger() SFLogger

GetLogger return logger that is not public

type TypedNullTime

type TypedNullTime struct {
	Time   sql.NullTime
	TzType timezoneType
}

type UUID

type UUID [16]byte

UUID is a RFC4122 compliant uuid type

func NewUUID

func NewUUID() UUID

NewUUID creates a new clickzetta UUID

func ParseUUID

func ParseUUID(str string) UUID

ParseUUID parses a string of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx into its UUID form

func (UUID) String

func (u UUID) String() string

Directories

Path Synopsis
protos

Jump to

Keyboard shortcuts

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