Documentation
¶
Index ¶
- Constants
- Variables
- func DatabaseIdentifier(database string) table.Identifier
- func TableIdentifier(database, tableName string) table.Identifier
- 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, identifier table.Identifier, ...) (_ table.Metadata, _ string, err error)
- func (c *Catalog) CreateNamespace(ctx context.Context, namespace table.Identifier, props iceberg.Properties) error
- func (c *Catalog) CreateTable(ctx context.Context, identifier table.Identifier, schema *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) DropTable(ctx context.Context, identifier table.Identifier) (err 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) PurgeTable(ctx context.Context, identifier table.Identifier) error
- func (c *Catalog) RegisterTable(ctx context.Context, identifier table.Identifier, metadataLocation string) (*table.Table, error)
- func (c *Catalog) RenameTable(ctx context.Context, from, to table.Identifier) (_ *table.Table, err error)
- func (c *Catalog) UpdateNamespaceProperties(ctx context.Context, namespace table.Identifier, removals []string, ...) (catalog.PropertiesUpdateSummary, error)
- type HiveClient
- type HiveLock
- type HiveOptions
- type Option
Constants ¶
const ( // URI is the Thrift URI for the Hive Metastore (e.g., "thrift://localhost:9083") URI = "uri" // Warehouse is the default warehouse location for tables Warehouse = "warehouse" TableTypeKey = "table_type" TableTypeIceberg = "ICEBERG" TableTypeExternalTable = "EXTERNAL_TABLE" // Ref: https://github.com/apache/hive/blob/7060d94843fdbc548445db6aac84dd60b44641ee/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/TableType.java#L27 TableTypeVirtualView = "VIRTUAL_VIEW" // Ref: https://github.com/apache/iceberg/blob/2f170322d425a4c6267a9033efa2107c9bfc53db/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveOperationsBase.java#L57 TableTypeIcebergView = "ICEBERG_VIEW" MetadataLocationKey = "metadata_location" PreviousMetadataLocationKey = "previous_metadata_location" ExternalKey = "EXTERNAL" StorageHandlerKey = "storage_handler" IcebergStorageHandler = "org.apache.iceberg.mr.hive.HiveIcebergStorageHandler" GCEnabledKey = "gc.enabled" ExternalTablePurgeKey = "external.table.purge" // Lock configuration property keys. // // Primary names match the Java Hive catalog properties (integer milliseconds). // Legacy Go keys remain accepted as aliases so existing configs keep working; // when both forms are set, the Java key wins. // Ref: https://iceberg.apache.org/docs/nightly/catalog-properties/#hive-metastore-configuration LockCheckMinWaitMs = "iceberg.hive.lock-check-min-wait-ms" LockCheckMaxWaitMs = "iceberg.hive.lock-check-max-wait-ms" // Legacy Go-specific aliases (Go duration strings, e.g. "100ms", "5s"). LockCheckMinWaitTime = "lock-check-min-wait-time" LockCheckMaxWaitTime = "lock-check-max-wait-time" // LockCheckRetries is Go-specific. Java bounds acquisition with // iceberg.hive.lock-timeout-ms instead of a retry count. LockCheckRetries = "lock-check-retries" // Default lock configuration values match the Java Hive catalog. DefaultLockCheckMinWaitTime = 50 * time.Millisecond // Java: 50ms DefaultLockCheckMaxWaitTime = 5 * time.Second // Java: 5000ms DefaultLockCheckRetries = 4 )
Variables ¶
var ErrLockAcquisitionFailed = errors.New("failed to acquire lock")
ErrLockAcquisitionFailed is returned when a lock cannot be acquired after all retries.
Functions ¶
func DatabaseIdentifier ¶
func DatabaseIdentifier(database string) table.Identifier
DatabaseIdentifier returns a database identifier for a Hive database.
func TableIdentifier ¶
func TableIdentifier(database, tableName string) table.Identifier
TableIdentifier returns a table identifier for a Hive table.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
func NewCatalog ¶
func NewCatalog(props iceberg.Properties, opts ...Option) (*Catalog, error)
func NewCatalogWithClient ¶
func NewCatalogWithClient(client HiveClient, props iceberg.Properties) *Catalog
func (*Catalog) CatalogType ¶
func (*Catalog) CheckNamespaceExists ¶
func (c *Catalog) CheckNamespaceExists(ctx context.Context, namespace table.Identifier) (bool, error)
CheckNamespaceExists checks if a namespace exists in the catalog.
func (*Catalog) CheckTableExists ¶
CheckTableExists checks if a table exists in the catalog.
func (*Catalog) CheckViewExists ¶
CheckViewExists checks if a view exists in the catalog.
func (*Catalog) Close ¶
Close releases the Hive client and the catalog's metrics reporter. Each close is isolated from the other so one failing does not skip the other and leak its resource — not just when a close returns an error (errors.Join already keeps both), but when it panics: a bare errors.Join(c.client.Close(), c.reporter.Close()) would let a panic in the first close abort the second. Recovered panics are converted to errors and joined with any close errors. Callers holding a catalog.Catalog can reach this via a catalog.Closer type assertion.
func (*Catalog) CommitTable ¶
func (*Catalog) CreateNamespace ¶
func (c *Catalog) CreateNamespace(ctx context.Context, namespace table.Identifier, props iceberg.Properties) error
CreateNamespace creates a new namespace in the catalog.
func (*Catalog) CreateTable ¶
func (*Catalog) CreateView ¶ added in v0.6.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. It uses the same signature as the REST catalog: identifier, version (with SQL representations), schema, and optional CreateViewOpt for location and properties. Returns the created *view.View, or an error if the namespace is missing, a view/table already exists, or creation fails.
func (*Catalog) DropNamespace ¶
DropNamespace drops a namespace 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]
ListTables returns a list of table identifiers in the given namespace.
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 given namespace.
func (*Catalog) LoadNamespaceProperties ¶
func (c *Catalog) LoadNamespaceProperties(ctx context.Context, namespace table.Identifier) (iceberg.Properties, error)
LoadNamespaceProperties loads the properties for a namespace.
func (*Catalog) PurgeTable ¶ added in v0.7.0
func (*Catalog) RegisterTable ¶ added in v0.6.0
func (c *Catalog) RegisterTable(ctx context.Context, identifier table.Identifier, metadataLocation string) (*table.Table, error)
RegisterTable adds an existing Iceberg table to the Hive metastore
func (*Catalog) RenameTable ¶
func (*Catalog) UpdateNamespaceProperties ¶
func (c *Catalog) UpdateNamespaceProperties(ctx context.Context, namespace table.Identifier, removals []string, updates iceberg.Properties, ) (catalog.PropertiesUpdateSummary, error)
UpdateNamespaceProperties updates the properties for a namespace.
type HiveClient ¶
type HiveClient interface {
Close() error
GetDatabase(ctx context.Context, name string) (*hive_metastore.Database, error)
CreateDatabase(ctx context.Context, database *hive_metastore.Database) error
AlterDatabase(ctx context.Context, dbname string, db *hive_metastore.Database) error
DropDatabase(ctx context.Context, name string, deleteData, cascade bool) error
GetAllDatabases(ctx context.Context) ([]string, error)
GetTable(ctx context.Context, dbName, tableName string) (*hive_metastore.Table, error)
CreateTable(ctx context.Context, tbl *hive_metastore.Table) error
AlterTable(ctx context.Context, dbName, tableName string, newTbl *hive_metastore.Table) error
DropTable(ctx context.Context, dbName, tableName string, deleteData bool) error
GetTables(ctx context.Context, dbName, pattern string) ([]string, error)
Lock(ctx context.Context, request *hive_metastore.LockRequest) (*hive_metastore.LockResponse, error)
CheckLock(ctx context.Context, lockId int64) (*hive_metastore.LockResponse, error)
Unlock(ctx context.Context, lockId int64) error
}
type HiveOptions ¶
type HiveOptions struct {
URI string
Warehouse string
// Lock configuration for atomic commits
LockMinWaitTime time.Duration
LockMaxWaitTime time.Duration
LockRetries int
// contains filtered or unexported fields
}
func NewHiveOptions ¶
func NewHiveOptions() *HiveOptions
func (*HiveOptions) ApplyProperties ¶
func (o *HiveOptions) ApplyProperties(props iceberg.Properties)
type Option ¶
type Option func(*HiveOptions)
func WithProperties ¶
func WithProperties(props iceberg.Properties) Option