Documentation
¶
Overview ¶
Package catalog provides an interface for Catalog implementations along with a registry for registering catalog implementations.
Subpackages of this package provide some default implementations for select catalog types which will register themselves if imported. For instance, adding the following import:
import _ "github.com/apache/iceberg-go/catalog/rest"
Will register the REST catalog implementation.
Example (MultiTableTransaction) ¶
This example demonstrates atomic multi-table commits using the MultiTableTransaction API. Changes to multiple tables are collected and committed in a single all-or-nothing request.
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package main
import (
"context"
"errors"
"fmt"
"iter"
"github.com/apache/iceberg-go"
"github.com/apache/iceberg-go/catalog"
"github.com/apache/iceberg-go/table"
)
// exampleCatalog is a minimal Catalog + TransactionalCatalog stub
// for the runnable example.
type exampleCatalog struct {
tables map[string]*table.Table
}
func (c *exampleCatalog) Close() error { return nil }
func (c *exampleCatalog) Name() string { return "example" }
func (c *exampleCatalog) CatalogType() catalog.Type { return catalog.REST }
func (c *exampleCatalog) CommitTransaction(_ context.Context, _ []table.TableCommit) error {
return nil
}
func (c *exampleCatalog) LoadTable(_ context.Context, id table.Identifier) (*table.Table, error) {
if t, ok := c.tables[id[len(id)-1]]; ok {
return t, nil
}
return nil, errors.New("table not found")
}
func (c *exampleCatalog) ListTables(context.Context, table.Identifier) iter.Seq2[table.Identifier, error] {
return nil
}
func (c *exampleCatalog) CreateTable(context.Context, table.Identifier, *iceberg.Schema, ...catalog.CreateTableOpt) (*table.Table, error) {
return nil, nil
}
func (c *exampleCatalog) CommitTable(context.Context, table.Identifier, []table.Requirement, []table.Update) (table.Metadata, string, error) {
return nil, "", nil
}
func (c *exampleCatalog) DropTable(context.Context, table.Identifier) error { return nil }
func (c *exampleCatalog) PurgeTable(context.Context, table.Identifier) error { return nil }
func (c *exampleCatalog) RenameTable(context.Context, table.Identifier, table.Identifier) (*table.Table, error) {
return nil, nil
}
func (c *exampleCatalog) CheckTableExists(context.Context, table.Identifier) (bool, error) {
return false, nil
}
func (c *exampleCatalog) ListNamespaces(context.Context, table.Identifier) ([]table.Identifier, error) {
return nil, nil
}
func (c *exampleCatalog) CreateNamespace(context.Context, table.Identifier, iceberg.Properties) error {
return nil
}
func (c *exampleCatalog) DropNamespace(context.Context, table.Identifier) error { return nil }
func (c *exampleCatalog) CheckNamespaceExists(context.Context, table.Identifier) (bool, error) {
return false, nil
}
func (c *exampleCatalog) LoadNamespaceProperties(context.Context, table.Identifier) (iceberg.Properties, error) {
return nil, nil
}
func (c *exampleCatalog) UpdateNamespaceProperties(context.Context, table.Identifier, []string, iceberg.Properties) (catalog.PropertiesUpdateSummary, error) {
return catalog.PropertiesUpdateSummary{}, nil
}
func makeExampleTable(ns, name string) *table.Table {
schema := iceberg.NewSchema(0,
iceberg.NestedField{ID: 1, Name: "id", Type: iceberg.PrimitiveTypes.Int64, Required: true},
)
meta, _ := table.NewMetadata(schema, iceberg.UnpartitionedSpec,
table.UnsortedSortOrder, "s3://bucket/"+name,
iceberg.Properties{table.PropertyFormatVersion: "2"})
return table.New(table.Identifier{ns, name}, meta, "", nil, nil)
}
// This example demonstrates atomic multi-table commits using the
// MultiTableTransaction API. Changes to multiple tables are collected
// and committed in a single all-or-nothing request.
func main() {
ctx := context.Background()
tbl1 := makeExampleTable("db", "orders")
tbl2 := makeExampleTable("db", "inventory")
cat := &exampleCatalog{
tables: map[string]*table.Table{
"orders": tbl1,
"inventory": tbl2,
},
}
// Create a multi-table transaction from the catalog.
mtx, err := catalog.NewMultiTableTransaction(cat)
if err != nil {
panic(err)
}
// Build changes on each table via individual transactions.
tx1 := tbl1.NewTransaction()
_ = tx1.SetProperties(map[string]string{"pipeline": "v2"})
_ = mtx.AddTransaction(tx1)
tx2 := tbl2.NewTransaction()
_ = tx2.SetProperties(map[string]string{"pipeline": "v2"})
_ = mtx.AddTransaction(tx2)
// Option A: Commit only — caller reloads tables manually.
err = mtx.Commit(ctx)
if err != nil {
panic(err)
}
fmt.Println("committed 2 tables atomically")
// Option B: CommitAndReload commits and reloads all tables.
// tables, err := mtx.CommitAndReload(ctx)
}
Output: committed 2 tables atomically
Index ¶
- Variables
- func As[T any](cat Catalog) (T, bool)
- func GetRegisteredCatalogs() []string
- func MustRegister(catalogType string, reg Registrar)
- func NamespaceFromIdent(ident table.Identifier) table.Identifier
- func ObjectNameFromIdent(ident table.Identifier) string
- func Register(catalogType string, reg Registrar)
- func RollbackView(ctx context.Context, cat Catalog, ident table.Identifier, versionID int64) (*view.View, error)
- func ToIdentifier(ident ...string) table.Identifier
- func Unregister(catalogType string)
- func ValidateFunctionIdentifier(ident table.Identifier) error
- func ValidateNamespaceIdentifier(ident table.Identifier) error
- func ValidateTableIdentifier(ident table.Identifier) error
- func ValidateViewIdentifier(ident table.Identifier) error
- type Catalog
- type CreateTableCfg
- type CreateTableOpt
- type CreateViewCfg
- type CreateViewOpt
- type MultiTableTransaction
- type NamespaceCatalog
- type PropertiesUpdateSummary
- type PurgeableCatalog
- type RefreshableCredentialCatalog
- type RegisterableCatalog
- type Registrar
- type RegistrarFunc
- type Registry
- func (r *Registry) Clone() *Registry
- func (r *Registry) Load(ctx context.Context, name string, props iceberg.Properties) (Catalog, error)
- func (r *Registry) MustRegister(catalogType string, reg Registrar)
- func (r *Registry) Names() []string
- func (r *Registry) Register(catalogType string, reg Registrar) error
- func (r *Registry) Unregister(catalogType string)
- type RenamableViewCatalog
- type TableCatalog
- type TransactionalCatalog
- type Type
- type UpdatableViewCatalog
- type ViewCatalog
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoSuchTable is returned when a table does not exist in the catalog. ErrNoSuchTable = errors.New("table does not exist") ErrNoSuchNamespace = errors.New("namespace does not exist") ErrInvalidIdentifier = errors.New("identifier is invalid") ErrNamespaceAlreadyExists = errors.New("namespace already exists") ErrTableAlreadyExists = errors.New("table already exists") ErrCatalogNotFound = errors.New("catalog type not registered") ErrNamespaceNotEmpty = errors.New("namespace is not empty") ErrNoSuchView = errors.New("view does not exist") ErrViewAlreadyExists = errors.New("view already exists") ErrNoSuchFunction = errors.New("function does not exist") ErrEmptyCommitList = errors.New("commit list must not be empty") ErrMissingIdentifier = errors.New("every table commit must have a valid identifier") )
Functions ¶
func As ¶ added in v0.8.0
As finds the first catalog in the wrapping chain that implements T. Catalog decorators can expose a wrapped catalog with Unwrap() Catalog. The outermost catalog is checked first, allowing decorators to intercept optional operations. Unwrap may return nil to end the chain, and the chain must terminate without cycles.
func GetRegisteredCatalogs ¶ added in v0.2.0
func GetRegisteredCatalogs() []string
GetRegisteredCatalogs returns the registered catalog types in sorted order.
func MustRegister ¶ added in v0.8.0
MustRegister registers a catalog factory in the default registry or panics.
func NamespaceFromIdent ¶
func NamespaceFromIdent(ident table.Identifier) table.Identifier
func ObjectNameFromIdent ¶ added in v0.7.0
func ObjectNameFromIdent(ident table.Identifier) string
ObjectNameFromIdent returns the name of a catalog object (a table, view, or function), which is the last element of its identifier.
func Register ¶ added in v0.2.0
Register adds a factory to the process-wide default registry, replacing any existing factory of the same type. For compatibility, it panics on a nil registrar and permits an empty catalog type.
func RollbackView ¶ added in v0.8.0
func RollbackView(ctx context.Context, cat Catalog, ident table.Identifier, versionID int64) (*view.View, error)
RollbackView makes a retained version current through an updatable catalog. It preserves version IDs and schemas and records the rollback in version history. The view UUID requirement prevents changing a dropped/recreated view. Missing or expired versions are rejected. Rolling back can also fail if the target removes a SQL dialect and replace.drop-dialect.allowed is false.
func ToIdentifier ¶ added in v0.2.0
func ToIdentifier(ident ...string) table.Identifier
func Unregister ¶ added in v0.2.0
func Unregister(catalogType string)
Unregister removes a catalog factory from the default registry.
func ValidateFunctionIdentifier ¶ added in v0.7.0
func ValidateFunctionIdentifier(ident table.Identifier) error
ValidateFunctionIdentifier checks that an identifier contains at least one valid namespace level and a function name.
func ValidateNamespaceIdentifier ¶ added in v0.7.0
func ValidateNamespaceIdentifier(ident table.Identifier) error
ValidateNamespaceIdentifier checks that an identifier contains at least one namespace level and no null characters. Other namespace component rules are intentionally left to the catalog implementation so existing namespaces remain readable across clients.
func ValidateTableIdentifier ¶ added in v0.7.0
func ValidateTableIdentifier(ident table.Identifier) error
ValidateTableIdentifier checks that an identifier contains at least one valid namespace level and a table name.
func ValidateViewIdentifier ¶ added in v0.7.0
func ValidateViewIdentifier(ident table.Identifier) error
ValidateViewIdentifier checks that an identifier contains at least one valid namespace level and a view name.
Types ¶
type Catalog ¶
type Catalog interface {
io.Closer
// Name returns the catalog's configured logical name. Glue and Hive
// catalogs built without WithName return "glue" and "hive".
Name() string
// CatalogType returns the type of the catalog.
CatalogType() Type
TableCatalog
NamespaceCatalog
}
Catalog combines universal table and namespace operations with catalog identity and resource lifecycle. Implementations must release catalog-owned resources in Close. Ownership of constructor-supplied dependencies depends on the implementation. Using a catalog after Close is unsupported; repeated Close calls have implementation-specific behavior.
After v1, add new capabilities as optional interfaces, never as methods on Catalog, to avoid breaking third-party catalog implementations.
func Load ¶ added in v0.2.0
Load returns a catalog that must be closed by the caller to release its reporter, transports, and other catalog-owned resources.
Load allows loading a specific catalog by URI and properties.
This is utilized alongside Register/Unregister to not only allow easier catalog loading but also to allow for custom catalog implementations to be registered and loaded external to this module.
The name parameter is used to look up the catalog configuration, if one exists, that was loaded from the configuration file, ".iceberg-go.yaml". By default, the config file is loaded from the user's home directory, but the directory can be changed by setting the GOICEBERG_HOME environment variable to the path of the directory containing the ".iceberg-go.yaml" file. The name will also be passed to the registered GetCatalog function.
The catalog registry will be checked for the catalog's type. The "type" property is used first to search the catalog registry, with the passed properties taking priority over any loaded config.
If there is no "type" in the configuration and no "type" in the passed in properties, then the "uri" property is used to look up the catalog by checking the scheme. Again, if there is an "uri" key set in the passed in "props" it will take priority over the configuration.
Currently, the following catalog types are registered by default:
"glue" for AWS Glue Data Catalog, the rest of the URI is ignored, all configuration should be provided using the properties. "glue.region", "glue.endpoint", "glue.max-retries", etc. Default AWS credentials are used if found, or can be overridden by setting "glue.access-key-id", "glue.secret-access-key", and "glue.session-token".
"rest" for a REST API catalog, if the properties have an "uri" key, then that will be used as the REST endpoint, otherwise the URI is used as the endpoint. The REST catalog also registers "http" and "https" so that Load with a http/s URI will automatically load the REST Catalog.
type CreateTableCfg ¶ added in v0.3.0
type CreateTableCfg struct {
PartitionSpec *iceberg.PartitionSpec
SortOrder table.SortOrder
// StagedUpdates holds additional table.Update operations that cause
// the REST catalog to use a two-phase staged creation. Phase 1
// sends a minimal create with stage-create=true; phase 2 commits
// with an assert-create requirement and all updates atomically.
// Non-REST catalogs ignore this field.
StagedUpdates []table.Update
// contains filtered or unexported fields
}
CreateTableCfg represents the configuration used for CreateTable operations
func NewCreateTableCfg ¶ added in v0.4.0
func NewCreateTableCfg() CreateTableCfg
type CreateTableOpt ¶ added in v0.2.0
type CreateTableOpt func(*CreateTableCfg)
func WithLocation ¶ added in v0.2.0
func WithLocation(location string) CreateTableOpt
func WithPartitionSpec ¶ added in v0.2.0
func WithPartitionSpec(spec *iceberg.PartitionSpec) CreateTableOpt
func WithProperties ¶ added in v0.2.0
func WithProperties(props iceberg.Properties) CreateTableOpt
func WithSortOrder ¶ added in v0.2.0
func WithSortOrder(order table.SortOrder) CreateTableOpt
func WithStagedUpdates ¶ added in v0.5.0
func WithStagedUpdates(updates ...table.Update) CreateTableOpt
WithStagedUpdates provides additional table.Update operations that cause the REST catalog to use two-phase staged creation. This is useful for atomically creating a table with a custom UUID, initial snapshots, or snapshot references. Use constructors from the table package (e.g. table.NewAssignUUIDUpdate, table.NewAddSnapshotUpdate, table.NewSetSnapshotRefUpdate).
type CreateViewCfg ¶ added in v0.5.0
type CreateViewCfg struct {
// contains filtered or unexported fields
}
CreateViewCfg represents the configuration used for CreateView operations
func NewCreateViewCfg ¶ added in v0.5.0
func NewCreateViewCfg() CreateViewCfg
type CreateViewOpt ¶ added in v0.5.0
type CreateViewOpt func(*CreateViewCfg)
func WithViewLocation ¶ added in v0.5.0
func WithViewLocation(location string) CreateViewOpt
func WithViewProperties ¶ added in v0.5.0
func WithViewProperties(config iceberg.Properties) CreateViewOpt
type MultiTableTransaction ¶ added in v0.6.0
type MultiTableTransaction struct {
// contains filtered or unexported fields
}
MultiTableTransaction collects changes across multiple tables and commits them atomically via TransactionalCatalog.CommitTransaction.
A MultiTableTransaction must not be used concurrently from multiple goroutines.
Usage:
mtx, err := catalog.NewMultiTableTransaction(cat)
// ... err check ...
tx1 := tbl1.NewTransaction()
tx1.SetProperties(map[string]string{"key": "val"})
mtx.AddTransaction(tx1)
tx2 := tbl2.NewTransaction()
// ... build changes on tx2 ...
mtx.AddTransaction(tx2)
err = mtx.Commit(ctx)
func NewMultiTableTransaction ¶ added in v0.6.0
func NewMultiTableTransaction(cat Catalog) (*MultiTableTransaction, error)
NewMultiTableTransaction creates a new multi-table transaction backed by the given catalog. Returns an error if the catalog does not expose TransactionalCatalog, including through an Unwrap chain.
func (*MultiTableTransaction) AddTransaction ¶ added in v0.6.0
func (m *MultiTableTransaction) AddTransaction(tx *table.Transaction) error
AddTransaction adds a table transaction to be committed atomically with all other transactions in this multi-table transaction. Returns an error if the transaction is nil, already committed, or targets a table that was already added.
A transaction may still be empty here and gain updates before Commit, so emptiness is only decided when the payloads are built.
func (*MultiTableTransaction) Commit ¶ added in v0.6.0
func (m *MultiTableTransaction) Commit(ctx context.Context) error
Commit extracts pending changes from all added transactions and commits them atomically. On success, all transactions are marked as committed. On failure, no transactions are marked committed.
A retry must be rebuilt from freshly loaded tables: each payload asserts the branch head its transaction read.
Transactions that stage no updates are left out of the request, since a catalog may reject a table change carrying none. They are still marked committed. A request with nothing left to send is not made.
PostCommit hooks are not executed. Because the multi-table commit endpoint returns 204 No Content, callers must LoadTable individually to obtain updated metadata.
func (*MultiTableTransaction) CommitAndReload ¶ added in v0.6.0
CommitAndReload commits the multi-table transaction atomically and then reloads all affected tables from the catalog. This is a convenience method that combines MultiTableTransaction.Commit with individual LoadTable calls, since the multi-table commit endpoint returns 204 No Content and does not include updated metadata.
On commit failure, no tables are reloaded and the error is returned. On partial reload failure (commit succeeded but a LoadTable fails), the successfully loaded tables are still returned alongside the error.
type NamespaceCatalog ¶ added in v0.8.0
type NamespaceCatalog interface {
// ListNamespaces returns the namespaces one level below parent, or the
// top-level namespaces when parent is empty.
ListNamespaces(ctx context.Context, parent table.Identifier) ([]table.Identifier, error)
// CreateNamespace tells the catalog to create a new namespace with the given properties
CreateNamespace(ctx context.Context, namespace table.Identifier, props iceberg.Properties) error
// DropNamespace drops an empty namespace. It returns ErrNamespaceNotEmpty
// while the namespace holds tables, views, or child namespaces.
DropNamespace(ctx context.Context, namespace table.Identifier) error
// CheckNamespaceExists returns if the namespace exists
CheckNamespaceExists(ctx context.Context, namespace table.Identifier) (bool, error)
// LoadNamespaceProperties returns the current properties in the catalog for
// a given namespace
LoadNamespaceProperties(ctx context.Context, namespace table.Identifier) (iceberg.Properties, error)
// UpdateNamespaceProperties allows removing, adding, and/or updating properties of a namespace
UpdateNamespaceProperties(ctx context.Context, namespace table.Identifier,
removals []string, updates iceberg.Properties) (PropertiesUpdateSummary, error)
}
NamespaceCatalog contains the namespace operations supported by every catalog. All built-in catalogs implement these operations.
type PropertiesUpdateSummary ¶
type PurgeableCatalog ¶ added in v0.8.0
type PurgeableCatalog interface {
PurgeTable(ctx context.Context, identifier table.Identifier) error
}
PurgeableCatalog is the small table purge interface embedded by Catalog. Every Catalog must support PurgeTable, which removes the catalog entry and performs best-effort physical file deletion.
For REST catalogs the purge is delegated server-side. For client-side catalogs (SQL, Glue, Hive, Hadoop) the table is first dropped from the catalog, then all files under the table's table.Metadata.Location root, plus any referenced files written outside the root (e.g. via write.data.path or write.metadata.path table properties), are physically deleted.
File physical deletion is performed on a best-effort basis. If gc.enabled is set to false on the table metadata, physical deletion is skipped entirely. Any file-deletion, directory walk, or listing errors encountered are logged as warnings, and the operation succeeds (returns nil) so that the catalog drop remains the single source of truth.
type RefreshableCredentialCatalog ¶ added in v0.8.0
type RefreshableCredentialCatalog interface {
// RefreshTableCredentials loads temporarily-vended credentials for a previously
// loaded table, and returns a new/modified table instance with up-to-date credentials
// if the catalog is using temporarily-vended credentials for this table.
// In this case, the instance should be able to refresh its own credentials internally
// making it useful for use as a long-lived instance. For tables that do
// not have catalog-vended storage credentials, the table can be returned with no
// modifications.
//
// The main use-case for this method is to be able to make externally-created table
// instances compatible with catalog-based credential refreshes.
RefreshTableCredentials(ctx context.Context, tbl *table.Table) (*table.Table, error)
}
RefreshableCredentialCatalog is an optional interface implemented by catalogs that support temporarily-vended credentials. Temporarily-vended credentials scope object storage access to just files allowed by the user making a related request to the catalog. Callers should check for this capability via As:
if rc, ok := catalog.As[catalog.RefreshableCredentialCatalog](cat); ok {
refreshed, err := rc.RefreshTableCredentials(ctx, tbl)
if err == nil {
tbl = refreshed
}
}
Passing the type assertion does not guarantee that credentials can be vended. An implementation may still return an error, for example when the catalog service does not support vending credentials (the REST catalog returns rest.ErrEndpointNotSupported if the server does not advertise the credentials endpoint) or no longer knows the table (ErrNoSuchTable). On error the returned table is nil, and callers should keep using the original table.
type RegisterableCatalog ¶ added in v0.8.0
type RegisterableCatalog interface {
RegisterTable(ctx context.Context, identifier table.Identifier, metadataLocation string) (*table.Table, error)
}
RegisterableCatalog is an optional interface for catalogs that can register an existing table from its metadata file. Registration adds a catalog entry without creating a new table or rewriting its data.
REST, Hive, and Glue catalogs implement this interface. Callers should check for registration support with As:
if registerable, ok := catalog.As[catalog.RegisterableCatalog](cat); ok {
tbl, err := registerable.RegisterTable(ctx, ident, metadataLocation)
}
Backend support for registration does not guarantee that a given request will succeed (for example, if the table already exists).
type Registrar ¶ added in v0.2.0
type Registrar interface {
GetCatalog(ctx context.Context, catalogName string, props iceberg.Properties) (Catalog, error)
}
Registrar is a factory for creating Catalog instances, used for registering to use with LoadCatalog.
type RegistrarFunc ¶ added in v0.2.0
func (RegistrarFunc) GetCatalog ¶ added in v0.2.0
func (f RegistrarFunc) GetCatalog(ctx context.Context, catalogName string, props iceberg.Properties) (Catalog, error)
type Registry ¶ added in v0.8.0
type Registry struct {
// contains filtered or unexported fields
}
Registry holds catalog factories independently of the package-level default. The zero value is ready to use, and its methods are safe for concurrent use.
func NewRegistry ¶ added in v0.8.0
func NewRegistry() *Registry
NewRegistry returns an independent snapshot of the default registry, including backends already registered through side-effect imports. Future registration changes to either registry do not affect the other.
func (*Registry) Clone ¶ added in v0.8.0
Clone returns a snapshot with independent registrations and synchronization. Existing Registrar implementations are shared; callers should make sure their implementations are safe to use concurrently.
func (*Registry) Load ¶ added in v0.8.0
func (r *Registry) Load(ctx context.Context, name string, props iceberg.Properties) (Catalog, error)
Load resolves a catalog using only the factories registered in this registry. Configuration resolution matches the package-level Load function and uses the shared config.EnvConfig for named catalog settings.
func (*Registry) MustRegister ¶ added in v0.8.0
MustRegister registers a catalog factory or panics. Intended for package init.
func (*Registry) Register ¶ added in v0.8.0
Register adds a catalog factory to this registry. An existing catalog type is replaced. An empty name or nil registrar returns ErrInvalidArgument.
func (*Registry) Unregister ¶ added in v0.8.0
Unregister removes a catalog factory from this registry.
type RenamableViewCatalog ¶ added in v0.8.0
type RenamableViewCatalog interface {
// RenameView changes a view's identifier and returns the renamed view.
RenameView(ctx context.Context, from, to table.Identifier) (*view.View, error)
}
RenamableViewCatalog is an optional capability for renaming existing views. REST and SQL catalogs implement it; discover support with As.
type TableCatalog ¶ added in v0.8.0
type TableCatalog interface {
PurgeableCatalog
// CreateTable creates a new iceberg table in the catalog using the provided identifier
// and schema. Options can be used to optionally provide location, partition spec, sort order,
// and custom properties.
CreateTable(ctx context.Context, identifier table.Identifier, schema *iceberg.Schema, opts ...CreateTableOpt) (*table.Table, error)
// CommitTable commits the table metadata and updates to the catalog, returning the new metadata
CommitTable(ctx context.Context, identifier table.Identifier, requirements []table.Requirement, updates []table.Update) (table.Metadata, string, error)
// ListTables returns a list of table identifiers in the catalog, with the returned
// identifiers containing the information required to load the table via that catalog.
ListTables(ctx context.Context, namespace table.Identifier) iter.Seq2[table.Identifier, error]
// LoadTable loads a table from the catalog and returns a Table with the metadata.
LoadTable(ctx context.Context, identifier table.Identifier) (*table.Table, error)
// DropTable tells the catalog to drop the table entirely.
DropTable(ctx context.Context, identifier table.Identifier) error
// RenameTable tells the catalog to rename a given table by the identifiers
// provided, and then loads and returns the destination table
RenameTable(ctx context.Context, from, to table.Identifier) (*table.Table, error)
// CheckTableExists reports whether the table exists.
CheckTableExists(ctx context.Context, identifier table.Identifier) (bool, error)
}
TableCatalog contains the table operations supported by every catalog. Callers that only manage tables can depend on this narrower interface.
type TransactionalCatalog ¶ added in v0.6.0
type TransactionalCatalog interface {
CommitTransaction(ctx context.Context, commits []table.TableCommit) error
}
TransactionalCatalog is an optional interface implemented by catalogs that support atomic multi-table commits. Callers should check for this capability via As:
if tc, ok := catalog.As[catalog.TransactionalCatalog](cat); ok {
err := tc.CommitTransaction(ctx, commits)
}
The endpoint is all-or-nothing: either all table changes are applied atomically, or none are. On success the method returns nil; the caller must LoadTable individually to obtain updated metadata because the server returns 204 No Content.
type UpdatableViewCatalog ¶ added in v0.8.0
type UpdatableViewCatalog interface {
// UpdateView applies requirements and updates and returns the updated view.
UpdateView(ctx context.Context, ident table.Identifier, requirements []view.Requirement, updates []view.Update) (*view.View, error)
}
UpdatableViewCatalog is an optional capability for updating existing views. Discover support with As.
type ViewCatalog ¶ added in v0.8.0
type ViewCatalog interface {
// ListViews lists view identifiers in a namespace.
ListViews(ctx context.Context, namespace table.Identifier) iter.Seq2[table.Identifier, error]
// LoadView loads a view by its identifier.
LoadView(ctx context.Context, identifier table.Identifier) (*view.View, error)
// CreateView creates a view using the given version and schema.
CreateView(ctx context.Context, identifier table.Identifier, version *view.Version, schema *iceberg.Schema, opts ...CreateViewOpt) (*view.View, error)
// DropView removes an existing view.
DropView(ctx context.Context, identifier table.Identifier) error
// CheckViewExists reports whether the view exists.
CheckViewExists(ctx context.Context, identifier table.Identifier) (bool, error)
}
ViewCatalog is an optional capability for standard view operations. Use As to discover support on a Catalog, including through decorators. RenameView and UpdateView may be discovered separately through RenamableViewCatalog and UpdatableViewCatalog. RegisterView is not part of this interface.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package catalogtest provides a conformance suite that every catalog.Catalog implementation can run against itself, so that shared behavior is specified once rather than re-derived in each implementation's tests.
|
Package catalogtest provides a conformance suite that every catalog.Catalog implementation can run against itself, so that shared behavior is specified once rather than re-derived in each implementation's tests. |
|
Package dynamodb implements the Java-compatible AWS DynamoDB catalog.
|
Package dynamodb implements the Java-compatible AWS DynamoDB catalog. |
|
Package hadoop implements a catalog over a Hadoop-style warehouse directory.
|
Package hadoop implements a catalog over a Hadoop-style warehouse directory. |
|
googleauth
Package googleauth authenticates the REST catalog client with Google credentials, for catalogs such as BigLake.
|
Package googleauth authenticates the REST catalog client with Google credentials, for catalogs such as BigLake. |
|
internal/planfake
Package planfake provides a deterministic in-process REST scan-planning server for tests.
|
Package planfake provides a deterministic in-process REST scan-planning server for tests. |
|
sigv4
Package sigv4 provides AWS Signature Version 4 signing for the REST catalog client.
|
Package sigv4 provides AWS Signature Version 4 signing for the REST catalog client. |