database

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTableView

func AddTableView(ctx context.Context, tableName string, db *DuckDb, filters ...string) error

func AddTableViews

func AddTableViews(ctx context.Context, db *DuckDb, filters ...string) error

AddTableViews creates a view for each table in the data directory, applying the provided duck db filters to the view query

func EnsureDatabaseFile

func EnsureDatabaseFile(ctx context.Context) error

func GetRowCount

func GetRowCount(ctx context.Context, tableName string, partitionName *string) (int64, error)

func GetTableViewSchema

func GetTableViewSchema(ctx context.Context, viewName string) (map[string]string, error)

func GetTableViews

func GetTableViews(ctx context.Context) ([]string, error)

func ListPartitions added in v0.2.0

func ListPartitions(ctx context.Context) ([]string, error)

ListPartitions uses DuckDB to build a list of all partitions for all tables

Types

type DuckDb added in v0.2.0

type DuckDb struct {
	// duckDb connection
	*sql.DB
	// contains filtered or unexported fields
}

DuckDb provides a wrapper around the sql.DB connection to DuckDB with enhanced error handling for invalid parquet files. It automatically retries operations when encountering invalid parquet files, which can occur when files are being written concurrently. The wrapper also handles installation and loading of required DuckDB extensions, and manages the connection lifecycle.

func NewDuckDb added in v0.2.0

func NewDuckDb(opts ...DuckDbOpt) (*DuckDb, error)

func (*DuckDb) Exec added in v0.2.0

func (d *DuckDb) Exec(query string, args ...any) (sql.Result, error)

func (*DuckDb) ExecContext added in v0.2.0

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

func (*DuckDb) GetTempDir added in v0.4.0

func (d *DuckDb) GetTempDir() string

GetTempDir returns the temporary directory configured for DuckDB operations

func (*DuckDb) Query added in v0.2.0

func (d *DuckDb) Query(query string, args ...any) (*sql.Rows, error)

func (*DuckDb) QueryContext added in v0.2.0

func (d *DuckDb) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

func (*DuckDb) QueryRow added in v0.2.0

func (d *DuckDb) QueryRow(query string, args ...any) *sql.Row

func (*DuckDb) QueryRowContext added in v0.2.0

func (d *DuckDb) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

type DuckDbOpt added in v0.2.0

type DuckDbOpt func(*DuckDb)

DuckDbOpt is a function type that modifies a DuckDb instance. It's used to configure DuckDb instances with different options like extensions, database file, and temp directory.

func WithDbFile added in v0.2.0

func WithDbFile(filename string) DuckDbOpt

WithDbFile sets the database file path for the DuckDb instance. This can be used to specify a persistent database file or an in-memory database.

func WithDuckDbExtensions added in v0.2.0

func WithDuckDbExtensions(extensions []string) DuckDbOpt

WithDuckDbExtensions sets the list of DuckDB extensions to be installed and loaded. These extensions will be installed and loaded when the DuckDb instance is created.

func WithMaxMemoryMb added in v0.4.0

func WithMaxMemoryMb(maxMemoryMb int) DuckDbOpt

WithMaxMemoryMb sets the maximum memory limit for DuckDB. This can be used to control the memory usage of DuckDB operations.

func WithTempDir added in v0.2.0

func WithTempDir(dir string) DuckDbOpt

WithTempDir sets the temporary directory for DuckDB operations. This directory is used for temporary files during database operations. If not specified, the collection temp directory will be used.

Jump to

Keyboard shortcuts

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