clickhouse

package
v1.1.43 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package clickhouse has functionality for inspecting and changing Clickhouse tables +k8s:openapi-gen=true +k8s:defaulter-gen=TypeMeta

Index

Constants

View Source
const InvalidType = "__INVALID__"

InvalidType marks a model type that could not successfully be converted to a clickhouse type

Variables

This section is empty.

Functions

func AsClickhouseType

func AsClickhouseType(taxonomy *model.EventTaxonomy, typeStr string) string

AsClickhouseType converts the type `typeStr` in `taxonomy` to Clickhouse format

func MakeCreateTableQuery

func MakeCreateTableQuery(table *Table) string

MakeCreateTableQuery constructs an SQL statement for creating a table

Types

type Column

type Column struct {
	Name string `json:"name"`
	Type string `json:"type"`
	// Empty string, "DEFAULT", "ALIAS" or "MATERIALIZED"
	DefaultKind       string `json:"defaultKind,omitempty"`
	DefaultExpression string `json:"defaultExpression,omitempty"`
	TTL               string `json:"ttl,omitempty"`
	Codec             string `json:"codec,omitempty"`
	Comment           string `json:"comment,omitempty"`
}

Column describes a Clickhouse table column +k8s:deepcopy-gen=true

func (*Column) DeepCopy

func (in *Column) DeepCopy() *Column

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Column.

func (*Column) DeepCopyInto

func (in *Column) DeepCopyInto(out *Column)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (Column) Equals

func (c Column) Equals(other Column) bool

SameAs compares two columns (assumed to have the same Name) and returns whether they are equal.

func (Column) EquivalentTo

func (c Column) EquivalentTo(other Column, db *StatefulDB) bool

EquivalentTo compares two columns (assumed to have the same Name) and returns whether they are equal after applying some equality normalizations. For example, a non-nullable Int32 column without a default, and one with DEFAULT 0 will be treated as equal.

type StatefulDB

type StatefulDB struct {
	*sql.DB

	LogQueries bool
	QueryLog   []string
	// contains filtered or unexported fields
}

func NewLoggingStatefulDB

func NewLoggingStatefulDB() *StatefulDB

func NewStatefulDB

func NewStatefulDB() *StatefulDB

func (*StatefulDB) Exec

func (sd *StatefulDB) Exec(query string, args ...interface{}) (sql.Result, error)

func (*StatefulDB) ExecContext

func (sd *StatefulDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*StatefulDB) KnowsExpression

func (sd *StatefulDB) KnowsExpression(expr string) bool

func (*StatefulDB) LearnExpression

func (sd *StatefulDB) LearnExpression(in, normalized string)

func (*StatefulDB) MaybeObserveColumnNormalization

func (sd *StatefulDB) MaybeObserveColumnNormalization(t *Table, col *Column) error

func (*StatefulDB) NormalizeExpression

func (sd *StatefulDB) NormalizeExpression(expr string) string

func (*StatefulDB) ObserveColumnNormalization

func (sd *StatefulDB) ObserveColumnNormalization(oldCol, newCol *Column)

func (*StatefulDB) OpenDB

func (sd *StatefulDB) OpenDB(dsn string) (*sql.DB, error)

func (*StatefulDB) Query

func (sd *StatefulDB) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*StatefulDB) QueryContext

func (sd *StatefulDB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

type Table

type Table struct {
	Name         string            `json:"name"`
	DatabaseName string            `json:"databaseName"`
	ClusterName  string            `json:"clusterName,omitempty"`
	Engine       string            `json:"engine"`
	PartitionBy  string            `json:"partitionBy,omitempty"`
	PrimaryKey   string            `json:"primaryKey,omitempty"`
	OrderBy      string            `json:"orderBy,omitempty"`
	SampleBy     string            `json:"sampleBy,omitempty"`
	TTL          string            `json:"ttl,omitempty"`
	Settings     map[string]string `json:"settings,omitempty"`
	Columns      []*Column         `json:"columns,omitempty"`
}

Table describes a Clickhouse table. Supports only TABLE, not VIEW or MATERIALIZED VIEW. +k8s:deepcopy-gen=true

func (*Table) AddColumn

func (t *Table) AddColumn(col *Column, db *StatefulDB) error

AddColumn adds a column to the table through the `db` connection

func (*Table) DeepCopy

func (in *Table) DeepCopy() *Table

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Table.

func (*Table) DeepCopyInto

func (in *Table) DeepCopyInto(out *Table)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Table) DropColumn

func (t *Table) DropColumn(col *Column, db *StatefulDB) error

DropColumn drops a column from the table through the `db` connection

func (Table) Exists

func (t Table) Exists(db *StatefulDB) (bool, error)

func (*Table) GetColumn

func (t *Table) GetColumn(colName string) *Column

GetColumn returns a column with a given name (only looking at its state, does not query ClickHouse)

func (*Table) HasColumn

func (t *Table) HasColumn(colName string) bool

HasColumn tells whether this table has a column with a given name (only looking at its state, does not query ClickHouse)

func (Table) Inspect

func (t Table) Inspect(db *StatefulDB) (*Table, error)

Inspect returns a new Table struct populated with the current structure of the table, or an error

func (Table) InspectColumn

func (t Table) InspectColumn(columnName string, db *StatefulDB) (*Column, error)

InspectColumnOfTable populates `column` with the current structure of `column.Name` in `table`, or returns an error

func (*Table) ModifyColumn

func (t *Table) ModifyColumn(col *Column, db *StatefulDB) error

ModifyColumn changes the type of a column through the `db` connection

func (*Table) String

func (t *Table) String() string

type TableInspector

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

TableInspector :

func NewTableInspector

func NewTableInspector(db *sql.DB) *TableInspector

NewTableInspector creates a new TableReflector object

func (TableInspector) Inspect

func (i TableInspector) Inspect(databaseName, tableName string) (*Table, error)

func (TableInspector) InspectInto

func (i TableInspector) InspectInto(table *Table) error

InspectInto populates `table` with the current table structure, or returns an error

func (TableInspector) TableExists

func (i TableInspector) TableExists(database, table string) (bool, error)

TableExists tells whether a given table exists

Jump to

Keyboard shortcuts

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