sql

package
v0.0.0-...-62e415d Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DialectKey = "sql.dialect"
	DriverKey  = "sql.driver"
)
View Source
const (
	TableType = "TABLE"
	ViewType  = "VIEW"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

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

func NewCatalog

func NewCatalog(name string, db *sql.DB, dialect SupportedDialect, props iceberg.Properties) (*Catalog, error)

NewCatalog creates a new sql-based catalog using the provided sql.DB handle to perform any queries.

The dialect parameter determines the SQL dialect to use for query generation and must be one of the supported dialects, i.e. one of the exported SupportedDialect values. The separation here allows for the use of different drivers/databases provided they support the chosen sql dialect (e.g. if a particular database supports the MySQL dialect, then the database can still be used with this catalog even though it's not explicitly implemented).

If the "init_catalog_tables" property is set to "true", then creating the catalog will also attempt to to verify whether the necessary tables (iceberg_tables and iceberg_namespace_properties) exist, creating them if they do not already exist.

The environment variable ICEBERG_SQL_DEBUG can be set to automatically log the sql queries to the terminal: - ICEBERG_SQL_DEBUG=1 logs only failed queries - ICEBERG_SQL_DEBUG=2 logs all queries

All interactions with the db are performed within transactions to ensure atomicity and transactional isolation of catalog changes.

func (*Catalog) CatalogType

func (c *Catalog) CatalogType() catalog.Type

func (*Catalog) CheckNamespaceExists

func (c *Catalog) CheckNamespaceExists(ctx context.Context, namespace table.Identifier) (bool, error)

func (*Catalog) CheckTableExists

func (c *Catalog) CheckTableExists(ctx context.Context, identifier table.Identifier) (bool, error)

func (*Catalog) CheckViewExists

func (c *Catalog) CheckViewExists(ctx context.Context, identifier table.Identifier) (bool, error)

CheckViewExists returns true if a view exists in the catalog.

func (*Catalog) CommitTable

func (c *Catalog) CommitTable(ctx context.Context, ident table.Identifier, reqs []table.Requirement, updates []table.Update) (table.Metadata, string, error)

func (*Catalog) CreateNamespace

func (c *Catalog) CreateNamespace(ctx context.Context, namespace table.Identifier, props iceberg.Properties) error

func (*Catalog) CreateSQLTables

func (c *Catalog) CreateSQLTables(ctx context.Context) error

func (*Catalog) CreateTable

func (c *Catalog) CreateTable(ctx context.Context, ident table.Identifier, sc *iceberg.Schema, opts ...catalog.CreateTableOpt) (*table.Table, error)

func (*Catalog) CreateView

func (c *Catalog) CreateView(ctx context.Context, identifier table.Identifier, schema *iceberg.Schema, viewSQL string, props iceberg.Properties) error

CreateView creates a new view in the catalog.

func (*Catalog) DropNamespace

func (c *Catalog) DropNamespace(ctx context.Context, namespace table.Identifier) error

func (*Catalog) DropSQLTables

func (c *Catalog) DropSQLTables(ctx context.Context) error

func (*Catalog) DropTable

func (c *Catalog) DropTable(ctx context.Context, identifier table.Identifier) error

func (*Catalog) DropView

func (c *Catalog) DropView(ctx context.Context, identifier table.Identifier) error

DropView deletes a view from the catalog.

func (*Catalog) ListNamespaces

func (c *Catalog) ListNamespaces(ctx context.Context, parent table.Identifier) ([]table.Identifier, error)

func (*Catalog) ListTables

func (c *Catalog) ListTables(ctx context.Context, namespace table.Identifier) iter.Seq2[table.Identifier, error]

func (*Catalog) ListViews

func (c *Catalog) ListViews(ctx context.Context, namespace table.Identifier) iter.Seq2[table.Identifier, error]

ListViews returns a list of view identifiers in the catalog.

func (*Catalog) LoadNamespaceProperties

func (c *Catalog) LoadNamespaceProperties(ctx context.Context, namespace table.Identifier) (iceberg.Properties, error)

func (*Catalog) LoadTable

func (c *Catalog) LoadTable(ctx context.Context, identifier table.Identifier) (*table.Table, error)

func (*Catalog) LoadView

func (c *Catalog) LoadView(ctx context.Context, identifier table.Identifier) (view.Metadata, error)

LoadView loads a view from the catalog.

func (*Catalog) Name

func (c *Catalog) Name() string

func (*Catalog) RenameTable

func (c *Catalog) RenameTable(ctx context.Context, from, to table.Identifier) (*table.Table, error)

func (*Catalog) UpdateNamespaceProperties

func (c *Catalog) UpdateNamespaceProperties(ctx context.Context, namespace table.Identifier, removals []string, updates iceberg.Properties) (catalog.PropertiesUpdateSummary, error)

type SupportedDialect

type SupportedDialect string
const (
	Postgres SupportedDialect = "postgres"
	MySQL    SupportedDialect = "mysql"
	SQLite   SupportedDialect = "sqlite"
	MSSQL    SupportedDialect = "mssql"
	Oracle   SupportedDialect = "oracle"
)

Jump to

Keyboard shortcuts

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