Documentation
¶
Index ¶
- Constants
- type Catalog
- func (c *Catalog) CatalogType() catalog.Type
- func (c *Catalog) CheckNamespaceExists(ctx context.Context, namespace table.Identifier) (bool, error)
- func (c *Catalog) CheckTableExists(ctx context.Context, identifier table.Identifier) (bool, error)
- func (c *Catalog) CheckViewExists(ctx context.Context, identifier table.Identifier) (bool, error)
- func (c *Catalog) Close() error
- func (c *Catalog) CommitTable(ctx context.Context, ident table.Identifier, reqs []table.Requirement, ...) (table.Metadata, string, error)
- func (c *Catalog) CreateNamespace(ctx context.Context, namespace table.Identifier, props iceberg.Properties) error
- func (c *Catalog) CreateSQLTables(ctx context.Context) error
- func (c *Catalog) CreateTable(ctx context.Context, ident table.Identifier, sc *iceberg.Schema, ...) (*table.Table, error)
- func (c *Catalog) CreateView(ctx context.Context, identifier table.Identifier, version *view.Version, ...) (*view.View, error)
- func (c *Catalog) DropNamespace(ctx context.Context, namespace table.Identifier) error
- func (c *Catalog) DropSQLTables(ctx context.Context) error
- func (c *Catalog) DropTable(ctx context.Context, identifier table.Identifier) error
- func (c *Catalog) DropView(ctx context.Context, identifier table.Identifier) error
- func (c *Catalog) ListNamespaces(ctx context.Context, parent table.Identifier) ([]table.Identifier, error)
- func (c *Catalog) ListTables(ctx context.Context, namespace table.Identifier) iter.Seq2[table.Identifier, error]
- func (c *Catalog) ListViews(ctx context.Context, namespace table.Identifier) iter.Seq2[table.Identifier, error]
- func (c *Catalog) LoadNamespaceProperties(ctx context.Context, namespace table.Identifier) (iceberg.Properties, error)
- func (c *Catalog) LoadTable(ctx context.Context, identifier table.Identifier) (*table.Table, error)
- func (c *Catalog) LoadView(ctx context.Context, identifier table.Identifier) (*view.View, error)
- func (c *Catalog) Name() string
- func (c *Catalog) PurgeTable(ctx context.Context, identifier table.Identifier) error
- func (c *Catalog) RenameTable(ctx context.Context, from, to table.Identifier) (*table.Table, error)
- func (c *Catalog) RenameView(ctx context.Context, from, to table.Identifier) (*view.View, error)
- func (c *Catalog) UpdateNamespaceProperties(ctx context.Context, namespace table.Identifier, removals []string, ...) (catalog.PropertiesUpdateSummary, error)
- func (c *Catalog) UpdateView(ctx context.Context, ident table.Identifier, requirements []view.Requirement, ...) (*view.View, error)
- type Option
- type SupportedDialect
Constants ¶
const ( DialectKey = "sql.dialect" DriverKey = "sql.driver" // SchemaVersionKey opts in to migrating a legacy V0 catalog (one that lacks // the iceberg_type column) up to the V1 schema. // // When set to SchemaVersionV1 the catalog issues the one-way ALTER TABLE // that adds the iceberg_type column; otherwise it stays on V0 and emits // column-free queries that never reference iceberg_type. SchemaVersionKey = "jdbc.schema-version" )
const ( TableType = "TABLE" ViewType = "VIEW" )
const (
SchemaVersionV1 = "V1"
)
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(ctx context.Context, name string, db *sql.DB, dialect SupportedDialect, props iceberg.Properties, opts ...Option) (*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 table creation and schema version queries run on ctx.
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.
SQLite callers that allow concurrent writers should configure WAL and a busy timeout in the driver DSN so the settings apply to every pooled connection, for example "?_busy_timeout=5000", which both drivers sqliteshim selects accept. Write transactions take SQLite's write lock before they read, so concurrent writers queue for up to the busy timeout, or until the context's deadline if that is sooner, instead of failing with SQLITE_BUSY. The driver's default applies when the DSN sets none: mattn waits 5000ms, while modernc does not wait, so CreateTable, CreateView and the other operations that retry on a lock conflict give up after about 310ms and the rest fail at once. NewCatalog does not mutate connection settings on the caller-owned db.
WithIORegistry selects a catalog-scoped FileIO registry. The default is the global registry.
func (*Catalog) CatalogType ¶
func (*Catalog) CheckNamespaceExists ¶ added in v0.3.0
func (*Catalog) CheckTableExists ¶ added in v0.3.0
CheckTableExists reports whether the identifier has a table row in the catalog. It does not validate that the referenced metadata file is readable.
func (*Catalog) CheckViewExists ¶ added in v0.4.0
CheckViewExists returns true if a view exists in the catalog.
func (*Catalog) Close ¶ added in v0.7.0
Close releases the catalog's metrics reporter. When the catalog opened its own database handle (the registry catalog.Load path), Close also closes that handle's connection pool; a handle supplied to NewCatalog stays owned by the caller and is left open. Close is required by catalog.Catalog.
func (*Catalog) CommitTable ¶
func (*Catalog) CreateNamespace ¶
func (c *Catalog) CreateNamespace(ctx context.Context, namespace table.Identifier, props iceberg.Properties) error
func (*Catalog) CreateTable ¶
func (*Catalog) CreateView ¶ added in v0.4.0
func (c *Catalog) CreateView(ctx context.Context, identifier table.Identifier, version *view.Version, schema *iceberg.Schema, opts ...catalog.CreateViewOpt) (*view.View, error)
CreateView creates a new view in the catalog.
func (*Catalog) DropNamespace ¶
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]
ListTables returns the table identifiers in a namespace.
func (*Catalog) ListViews ¶ added in v0.4.0
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) PurgeTable ¶ added in v0.7.0
func (*Catalog) RenameTable ¶
func (*Catalog) RenameView ¶ added in v0.8.0
RenameView atomically changes a view's identifier without moving its metadata.
func (*Catalog) UpdateNamespaceProperties ¶
func (c *Catalog) UpdateNamespaceProperties(ctx context.Context, namespace table.Identifier, removals []string, updates iceberg.Properties) (catalog.PropertiesUpdateSummary, error)
func (*Catalog) UpdateView ¶ added in v0.8.0
func (c *Catalog) UpdateView(ctx context.Context, ident table.Identifier, requirements []view.Requirement, updates []view.Update) (*view.View, error)
UpdateView applies view metadata updates using an atomic metadata-location swap.
type Option ¶ added in v0.8.0
type Option func(*catalogOptions)
func WithIORegistry ¶ added in v0.8.0
WithIORegistry selects the FileIO factories used by this SQL catalog. A nil registry uses the global default. The registry is shared, not copied, so subsequent Register and Unregister calls affect this catalog.
type SupportedDialect ¶
type SupportedDialect string
const ( Postgres SupportedDialect = "postgres" MySQL SupportedDialect = "mysql" SQLite SupportedDialect = "sqlite" MSSQL SupportedDialect = "mssql" Oracle SupportedDialect = "oracle" )