Documentation
¶
Overview ¶
Package clickhouse provides the ClickHouse database engine implementation.
ClickHouse is a column-oriented OLAP database. This engine:
Uses a custom DDL preprocessor that strips the ClickHouse-specific ENGINE clause from CREATE TABLE statements, then delegates to the SQLite parser, which handles balanced-parenthesis type wrappers (Nullable(T), Array(T), Map(K,V)) as single column-type strings.
Does NOT require a live ClickHouse connection for code generation. The reference Go driver is github.com/ClickHouse/clickhouse-go/v2 (pure Go), but no driver import is needed at code-generation time.
Type wrappers are unwrapped at the type-mapper level, not the parser level. The parser preserves "Nullable(String)" as-is; the mapper resolves it.
Package clickhouse provides the ClickHouse database engine implementation.
Type-mapping notes:
- Int8/16/32/64 → int8/int16/int32/int64; UInt8/16/32/64 → uint8/.../uint64.
- Int128/256, UInt128/256 → string (no native Go integer type).
- Float32/64 → float32/float64.
- String, FixedString(N) → string.
- Bool/Boolean → bool.
- UUID → string (override via custom_types).
- Date, Date32, DateTime, DateTime64(...) → time.Time (requires "time").
- JSON → json.RawMessage (requires "encoding/json").
- Decimal(p,s), Decimal64(s) → string (safe lossless default).
- Enum8(...), Enum16(...) → string.
- Nullable(T) → unwrapped to T with nullable=true, so the usual sql.NullX / *T resolution applies.
- Array(T) → []<goT>. The element type may itself be wrapped, e.g. Array(Nullable(String)) → []sql.NullString or []*string.
- LowCardinality(T) → same as T (storage hint, not a Go-type change).
- Map(K,V) → map[goK]goV for simple base-type keys/values; falls back to json.RawMessage for complex value types (e.g. Array values).
- Unknown types fall back to any.
Index ¶
- func New(opts engine.Options) (engine.Engine, error)
- type Engine
- func (e *Engine) BulkInsertStrategy() engine.BulkInsertStrategy
- func (e *Engine) ConnectionPool() engine.ConnectionPoolConfig
- func (e *Engine) DefaultDriver() string
- func (e *Engine) IsolationLevels() (supported []engine.IsolationLevel, defaultLevel engine.IsolationLevel)
- func (e *Engine) Name() string
- func (e *Engine) QueryHints() []engine.QueryHint
- func (e *Engine) SQLGenerator() engine.SQLGenerator
- func (e *Engine) SchemaParser() schemaparser.SchemaParser
- func (e *Engine) SupportsFeature(feature engine.Feature) bool
- func (e *Engine) TypeMapper() engine.TypeMapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements the engine.Engine interface for ClickHouse.
func (*Engine) BulkInsertStrategy ¶
func (e *Engine) BulkInsertStrategy() engine.BulkInsertStrategy
BulkInsertStrategy returns the :copyfrom strategy for ClickHouse. ClickHouse accepts multi-row VALUES statements with "?" positional parameters via the database/sql interface.
func (*Engine) ConnectionPool ¶
func (e *Engine) ConnectionPool() engine.ConnectionPoolConfig
ConnectionPool returns recommended connection pool settings for ClickHouse.
func (*Engine) DefaultDriver ¶
DefaultDriver returns the reference Go driver import path for ClickHouse.
github.com/ClickHouse/clickhouse-go/v2 is a pure-Go driver and does not require CGO. No live connection is needed for static code generation.
func (*Engine) IsolationLevels ¶
func (e *Engine) IsolationLevels() (supported []engine.IsolationLevel, defaultLevel engine.IsolationLevel)
IsolationLevels returns the supported transaction isolation levels for ClickHouse. ClickHouse supports read-committed semantics in lightweight transactions.
func (*Engine) QueryHints ¶
QueryHints returns available query hints for ClickHouse. ClickHouse does not expose SQL-level query hints via the standard driver.
func (*Engine) SQLGenerator ¶
func (e *Engine) SQLGenerator() engine.SQLGenerator
SQLGenerator returns the ClickHouse SQL generator.
func (*Engine) SchemaParser ¶
func (e *Engine) SchemaParser() schemaparser.SchemaParser
SchemaParser returns the schema parser. ClickHouse uses its own preprocessor (ENGINE-clause stripping) wrapping the SQLite parser, which handles balanced-parenthesis type wrappers natively.
func (*Engine) SupportsFeature ¶
SupportsFeature reports whether ClickHouse supports a specific feature.
func (*Engine) TypeMapper ¶
func (e *Engine) TypeMapper() engine.TypeMapper
TypeMapper returns the ClickHouse type mapper.