clickhouse

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package clickhouse provides a database provider for ClickHouse columnar databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider implements the Provider interface for ClickHouse ClickHouse has very different SQL syntax and concepts from other databases

func New

func New() *Provider

New creates a new ClickHouse provider

func (*Provider) ConvertFieldType

func (p *Provider) ConvertFieldType(field *types.Field) string

ConvertFieldType converts YAML field type to ClickHouse-specific SQL type

func (*Provider) GenerateAddColumn

func (p *Provider) GenerateAddColumn(tableName string, field *types.Field) string

GenerateAddColumn generates ALTER TABLE ADD COLUMN statement

func (*Provider) GenerateAlterColumn

func (p *Provider) GenerateAlterColumn(tableName string, oldField, newField *types.Field) (string, error)

GenerateAlterColumn generates an ALTER TABLE MODIFY COLUMN statement for ClickHouse.

func (*Provider) GenerateCreateIndex

func (p *Provider) GenerateCreateIndex(index *types.Index, tableName string) string

GenerateCreateIndex generates CREATE INDEX statement for ClickHouse ClickHouse doesn't have traditional indexes, but has skip indexes and primary keys

func (*Provider) GenerateCreateTable

func (p *Provider) GenerateCreateTable(schema *types.Schema, table *types.Table) (string, error)

GenerateCreateTable generates CREATE TABLE statement for ClickHouse

func (*Provider) GenerateDropColumn

func (p *Provider) GenerateDropColumn(tableName, columnName string) string

GenerateDropColumn generates ALTER TABLE DROP COLUMN statement

func (*Provider) GenerateDropForeignKeyConstraint

func (p *Provider) GenerateDropForeignKeyConstraint(tableName, constraintName string) string

GenerateDropForeignKeyConstraint returns a no-op comment because ClickHouse does not support foreign keys.

func (*Provider) GenerateDropIndex

func (p *Provider) GenerateDropIndex(indexName, tableName string) string

GenerateDropIndex generates DROP INDEX statement for ClickHouse

func (*Provider) GenerateDropTable

func (p *Provider) GenerateDropTable(tableName string) string

GenerateDropTable generates DROP TABLE statement

func (*Provider) GenerateDropTableCascade

func (p *Provider) GenerateDropTableCascade(tableName string) string

GenerateDropTableCascade generates a DROP TABLE statement for ClickHouse. ClickHouse does not support CASCADE on DROP TABLE, so this is an alias for GenerateDropTable.

func (*Provider) GenerateForeignKeyConstraint

func (p *Provider) GenerateForeignKeyConstraint(tableName, fieldName, referencedTable, constraintName, onDelete, onUpdate string) string

GenerateForeignKeyConstraint returns a no-op comment because ClickHouse does not support foreign keys.

func (*Provider) GenerateForeignKeyConstraints

func (p *Provider) GenerateForeignKeyConstraints(schema *types.Schema, junctionTables []types.Table) string

GenerateForeignKeyConstraints returns a no-op comment because ClickHouse does not support foreign keys.

func (*Provider) GenerateIndexes

func (p *Provider) GenerateIndexes(schema *types.Schema) string

GenerateIndexes generates skip-index comments for all tables in the schema.

func (*Provider) GenerateJunctionTable

func (p *Provider) GenerateJunctionTable(table1, table2 string, schema *types.Schema) (string, error)

GenerateJunctionTable generates the CREATE TABLE SQL for a many-to-many junction table.

func (*Provider) GenerateRenameColumn

func (p *Provider) GenerateRenameColumn(tableName, oldName, newName string) string

GenerateRenameColumn generates ALTER TABLE RENAME COLUMN statement

func (*Provider) GenerateRenameTable

func (p *Provider) GenerateRenameTable(oldName, newName string) string

GenerateRenameTable generates RENAME TABLE statement

func (*Provider) GenerateUpsert

func (p *Provider) GenerateUpsert(table string, conflictKeys []string, columns []string, valueLiterals [][]string) string

GenerateUpsert generates a plain INSERT INTO statement for ClickHouse. ClickHouse does not support traditional upsert; deduplication is handled by the table engine (e.g. ReplacingMergeTree). The valueLiterals are pre-formatted SQL literals and are not re-quoted.

func (*Provider) GetDatabaseSchema

func (p *Provider) GetDatabaseSchema(connectionString string) (*types.Schema, error)

GetDatabaseSchema extracts schema information from a ClickHouse database

func (*Provider) GetDefaultValue

func (p *Provider) GetDefaultValue(defaultRef string, defaults map[string]string) (string, error)

GetDefaultValue converts default value references to ClickHouse-specific values

func (*Provider) HistoryTableDDL

func (p *Provider) HistoryTableDDL() string

HistoryTableDDL returns the CREATE TABLE IF NOT EXISTS statement for the morphic_history migration-tracking table, using this provider's SQL dialect.

func (*Provider) InferForeignKeyType

func (p *Provider) InferForeignKeyType(referencedTable string, schema *types.Schema) string

InferForeignKeyType returns the SQL type to use for a foreign key column referencing the given table.

func (*Provider) IsAlreadyExistsError

func (p *Provider) IsAlreadyExistsError(err error) bool

IsAlreadyExistsError returns true when err indicates an object already exists in the database.

func (*Provider) IsNotFoundError

func (p *Provider) IsNotFoundError(err error) bool

IsNotFoundError returns true when err is a ClickHouse "doesn't exist" error.

func (*Provider) Placeholder

func (p *Provider) Placeholder(_ int) string

Placeholder returns the bind-parameter placeholder for the nth argument (1-indexed).

func (*Provider) QuoteName

func (p *Provider) QuoteName(name string) string

QuoteName quotes database identifiers for ClickHouse (backticks like MySQL)

func (*Provider) SetTypeMappings

func (p *Provider) SetTypeMappings(mappings map[string]string)

SetTypeMappings sets user-defined type mappings for this provider.

func (*Provider) SupportsOperation

func (p *Provider) SupportsOperation(operation string) bool

SupportsOperation checks if ClickHouse supports a specific operation

func (*Provider) TableColumns added in v1.12.0

func (p *Provider) TableColumns(db *sql.DB, tableName string) ([]string, error)

TableColumns is not yet implemented for ClickHouse.

Jump to

Keyboard shortcuts

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