clickhouse

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMacros added in v1.4.0

func ApplyMacros(cfg *config.Config, path string) string

func CalculateMaxFileSize added in v1.3.2

func CalculateMaxFileSize(cfg *config.Config) (int64, error)

func GetDisksByPaths added in v1.0.0

func GetDisksByPaths(disks []Disk, dataPaths []string) map[string]string

func IsClickhouseShadow

func IsClickhouseShadow(path string) bool

Types

type ClickHouse

type ClickHouse struct {
	Config *config.ClickHouseConfig
	// contains filtered or unexported fields
}

ClickHouse - provide

func (*ClickHouse) AttachPartitions

func (ch *ClickHouse) AttachPartitions(table metadata.TableMetadata, disks []Disk) error

AttachPartitions - execute ATTACH command for specific table

func (*ClickHouse) Close

func (ch *ClickHouse) Close()

Close - closing connection to ClickHouse

func (*ClickHouse) Connect

func (ch *ClickHouse) Connect() error

Connect - establish connection to ClickHouse

func (*ClickHouse) CreateDatabase

func (ch *ClickHouse) CreateDatabase(database, cluster string) error

CreateDatabase - create ClickHouse database

func (*ClickHouse) CreateDatabaseFromQuery added in v1.0.0

func (ch *ClickHouse) CreateDatabaseFromQuery(query, cluster string) error

func (*ClickHouse) CreateDatabaseWithEngine added in v1.0.0

func (ch *ClickHouse) CreateDatabaseWithEngine(database, engine, cluster string) error

func (*ClickHouse) CreateTable

func (ch *ClickHouse) CreateTable(table Table, query string, dropTable bool, onCluster string, version int) error

CreateTable - create ClickHouse table

func (*ClickHouse) CreateUserDefinedFunction added in v1.4.0

func (ch *ClickHouse) CreateUserDefinedFunction(name string, query string) error

func (*ClickHouse) DropTable added in v1.3.0

func (ch *ClickHouse) DropTable(table Table, query string, onCluster string, version int) error

DropTable - drop ClickHouse table

func (*ClickHouse) FreezeTable

func (ch *ClickHouse) FreezeTable(table *Table, name string) error

FreezeTable - freeze all partitions for table This way available for ClickHouse since v19.1

func (*ClickHouse) FreezeTableOldWay

func (ch *ClickHouse) FreezeTableOldWay(table *Table, name string) error

FreezeTableOldWay - freeze all partitions in table one by one This way using for ClickHouse below v19.1

func (*ClickHouse) GetAccessManagementPath added in v1.0.14

func (ch *ClickHouse) GetAccessManagementPath(disks []Disk) (string, error)

GetAccessManagementPath @todo think about how to properly extract access_management_path from /etc/clickhouse-server/

func (*ClickHouse) GetBackupTablesLegacy added in v1.0.0

func (ch *ClickHouse) GetBackupTablesLegacy(backupName string, disks []Disk) ([]metadata.TableMetadata, error)

GetBackupTablesLegacy - return list of backups of tables that can be restored

func (*ClickHouse) GetConn

func (ch *ClickHouse) GetConn() *sqlx.DB

GetConn - return current connection

func (*ClickHouse) GetDatabases added in v1.0.0

func (ch *ClickHouse) GetDatabases() ([]Database, error)

GetDatabases - return slice of all non system databases for backup

func (*ClickHouse) GetDefaultPath added in v1.0.0

func (ch *ClickHouse) GetDefaultPath(disks []Disk) (string, error)

func (*ClickHouse) GetDisks added in v1.0.0

func (ch *ClickHouse) GetDisks() ([]Disk, error)

GetDisks - return data from system.disks table

func (*ClickHouse) GetPartitions

func (ch *ClickHouse) GetPartitions(database, table string) (map[string][]metadata.Part, error)

GetPartitions - return slice of all partitions for a table

func (*ClickHouse) GetTables

func (ch *ClickHouse) GetTables(tablePattern string) ([]Table, error)

GetTables - return slice of all tables suitable for backup, MySQL and PorstgreSQL database engine shall be skipped

func (*ClickHouse) GetUserDefinedFunctions added in v1.4.0

func (ch *ClickHouse) GetUserDefinedFunctions() ([]Function, error)

func (*ClickHouse) GetVersion

func (ch *ClickHouse) GetVersion() (int, error)

GetVersion - returned ClickHouse version in number format Example value: 19001005

func (*ClickHouse) GetVersionDescribe added in v1.0.0

func (ch *ClickHouse) GetVersionDescribe() string

func (*ClickHouse) IsAtomic added in v1.0.0

func (ch *ClickHouse) IsAtomic(database string) (bool, error)

func (*ClickHouse) LogQuery added in v1.0.0

func (ch *ClickHouse) LogQuery(query string) string

func (*ClickHouse) Query added in v1.0.0

func (ch *ClickHouse) Query(query string, args ...interface{}) (sql.Result, error)

func (*ClickHouse) Queryx added in v1.0.0

func (ch *ClickHouse) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)

func (*ClickHouse) Select added in v1.0.0

func (ch *ClickHouse) Select(dest interface{}, query string, args ...interface{}) error

func (*ClickHouse) ShowCreateTable added in v1.0.0

func (ch *ClickHouse) ShowCreateTable(database, name string) string

func (*ClickHouse) SoftSelect added in v1.3.0

func (ch *ClickHouse) SoftSelect(dest interface{}, query string) error

type Database added in v1.0.0

type Database struct {
	Name   string `db:"name"`
	Engine string `db:"engine"`
	Query  string `db:"query"`
}

Database - Clickhouse system.databases struct

type Disk added in v1.0.0

type Disk struct {
	Name string `db:"name"`
	Path string `db:"path"`
	Type string `db:"type"`
}

type Function added in v1.4.0

type Function struct {
	Name        string `db:"name"`
	CreateQuery string `db:"create_query"`
}

Function - Clickhouse system.functions struct

type IsSystemTablesFieldPresent added in v1.2.1

type IsSystemTablesFieldPresent struct {
	IsDataPathPresent         int `db:"is_data_path_present"`
	IsDataPathsPresent        int `db:"is_data_paths_present"`
	IsUUIDPresent             int `db:"is_uuid_present"`
	IsCreateTableQueryPresent int `db:"is_create_table_query_present"`
	IsTotalBytesPresent       int `db:"is_total_bytes_present"`
}

IsSystemTablesFieldPresent - ClickHouse `system.tables` varius field flags

type Table

type Table struct {
	// common fields for all `clickhouse-server` versions
	Database string `db:"database"`
	Name     string `db:"name"`
	Engine   string `db:"engine"`
	// fields depends on `clickhouse-server` version
	DataPath         string   `db:"data_path,omitempty"` // For legacy support
	DataPaths        []string `db:"data_paths,omitempty"`
	UUID             string   `db:"uuid,omitempty"`
	CreateTableQuery string   `db:"create_table_query,omitempty"`
	TotalBytes       uint64   `db:"total_bytes,omitempty"`
	Skip             bool
}

Table - ClickHouse table struct

Jump to

Keyboard shortcuts

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