Documentation
¶
Overview ¶
Package clickhouse has functionality for inspecting and changing Clickhouse tables +k8s:openapi-gen=true +k8s:defaulter-gen=TypeMeta
Index ¶
- Constants
- func AsClickhouseType(taxonomy *model.EventTaxonomy, typeStr string) string
- func MakeCreateTableQuery(table *Table) string
- type Column
- type StatefulDB
- func (sd *StatefulDB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (sd *StatefulDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (sd *StatefulDB) KnowsExpression(expr string) bool
- func (sd *StatefulDB) LearnExpression(in, normalized string)
- func (sd *StatefulDB) MaybeObserveColumnNormalization(t *Table, col *Column) error
- func (sd *StatefulDB) NormalizeExpression(expr string) string
- func (sd *StatefulDB) ObserveColumnNormalization(oldCol, newCol *Column)
- func (sd *StatefulDB) OpenDB(dsn string) (*sql.DB, error)
- func (sd *StatefulDB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (sd *StatefulDB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- type Table
- func (t *Table) AddColumn(col *Column, db *StatefulDB) error
- func (in *Table) DeepCopy() *Table
- func (in *Table) DeepCopyInto(out *Table)
- func (t *Table) DropColumn(col *Column, db *StatefulDB) error
- func (t Table) Exists(db *StatefulDB) (bool, error)
- func (t *Table) GetColumn(colName string) *Column
- func (t *Table) HasColumn(colName string) bool
- func (t Table) Inspect(db *StatefulDB) (*Table, error)
- func (t Table) InspectColumn(columnName string, db *StatefulDB) (*Column, error)
- func (t *Table) ModifyColumn(col *Column, db *StatefulDB) error
- func (t *Table) String() string
- type TableInspector
Constants ¶
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 ¶
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 ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Column.
func (*Column) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (Column) Equals ¶
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 (*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) Query ¶
func (sd *StatefulDB) Query(query string, args ...interface{}) (*sql.Rows, error)
func (*StatefulDB) QueryContext ¶
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 ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Table.
func (*Table) DeepCopyInto ¶
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) GetColumn ¶
GetColumn returns a column with a given name (only looking at its state, does not query ClickHouse)
func (*Table) HasColumn ¶
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
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