clickhouse

package
v0.0.0-...-44e4a4a Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToFixedString

func BytesToFixedString(bytes []byte) string

BytesToFixedString converts a byte slice into a printable string that can be used as a ClickHouse FixedString(N) parameter.

func FormatNumberArray

func FormatNumberArray[N PrintableType](n []N) string

func FormatStringArray

func FormatStringArray(n []string) string

FormatStringArray converts a slice of strings into a ClickHouse array literal. Strings are escaped with \ and '.

func FormatUUIDAsFixedString

func FormatUUIDAsFixedString(id uuid.UUID) string

FormatUUIDAsFixedString converts a UUID into a printable string that can be used as a ClickHouse FixedString(16) parameter.

func FormatUUIDsAsFixedStringArray

func FormatUUIDsAsFixedStringArray(ids uuid.UUIDs) string

FormatUUIDsAsFixedStringArray converts a slice of UUIDs into a ClickHouse Array(FixedString(16)) compatible string.

func FuncMapToString

func FuncMapToString(fName string, ids []string) (string, []any)

func GetDatabaseConnection

func GetDatabaseConnection(
	clickHouseDSN string,
	opts *clickhouse.Options,
	logger *zap.Logger,
	pingDuration time.Duration,
) (clickhouse.Conn, error)

Types

type Conn

type Conn = clickhouse.Conn

Conn alias for ClickHouse connection for import convenience

type Identifier

type Identifier string

type Options

type Options = clickhouse.Options

Options alias for ClickHouse options for import convenience

type Parameters

type Parameters = clickhouse.Parameters

Parameters is alias for clickhouse parameters.

type PrintableType

type PrintableType interface {
	constraints.Integer | constraints.Float
}

type QueryBuilder

type QueryBuilder struct {
	Params clickhouse.Parameters
	// contains filtered or unexported fields
}

QueryBuilder helps construct a ClickHouse SQL query. Do not copy a non-zero QueryBuilder. QueryBuilder is not thread-safe. Provides a fluent interface to construct the query.

func NewQueryBuilder

func NewQueryBuilder() *QueryBuilder

func (*QueryBuilder) Args

func (qb *QueryBuilder) Args() clickhouse.Parameters

func (*QueryBuilder) Build

func (qb *QueryBuilder) Build(q string, elems ...any) *QueryBuilder

Build takes the given sql string replaces any ? with the equivalent indexed parameter and appends elems to the args slice.

func (*QueryBuilder) Context

func (qb *QueryBuilder) Context(ctx context.Context, options ...clickhouse.QueryOption) context.Context

Context returns a context to use with the ClickHouse driver query. It adds the query parameters to the context by default.

func (*QueryBuilder) SQL

func (qb *QueryBuilder) SQL() string

func (*QueryBuilder) WithParam

func (qb *QueryBuilder) WithParam(name string, value string) *QueryBuilder

WithParam adds a named parameter to the Params map.

type TimestampNano

type TimestampNano int64

type TypeValPair

type TypeValPair struct {
	ParamType string
	ParamVal  string
}

TypeValPair is a pair of (type, value) to use explicit parameter type and value.

Jump to

Keyboard shortcuts

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