hive

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
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"

	// Lock configuration property keys
	LockCheckMinWaitTime = "lock-check-min-wait-time"
	LockCheckMaxWaitTime = "lock-check-max-wait-time"
	LockCheckRetries     = "lock-check-retries"

	// Default lock configuration values
	DefaultLockCheckMinWaitTime = 100 * time.Millisecond // 100ms
	DefaultLockCheckMaxWaitTime = 60 * time.Second       // 1 minute
	DefaultLockCheckRetries     = 4
)

Variables

View Source
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 (c *Catalog) CatalogType() catalog.Type

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

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

CheckTableExists checks if a table exists in the catalog.

func (*Catalog) CheckViewExists

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

CheckViewExists checks if a view exists in the catalog.

func (*Catalog) Close

func (c *Catalog) Close() error

func (*Catalog) CommitTable

func (c *Catalog) CommitTable(ctx context.Context, identifier table.Identifier, requirements []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

CreateNamespace creates a new namespace in the catalog.

func (*Catalog) CreateTable

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

func (*Catalog) DropNamespace

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

DropNamespace drops a namespace from the catalog.

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 drops 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]

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) 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.View, error)

LoadView loads a view from the catalog.

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)

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 HiveLock

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

func (*HiveLock) LockID

func (l *HiveLock) LockID() int64

func (*HiveLock) Release

func (l *HiveLock) Release(ctx context.Context) 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

func WithURI

func WithURI(uri string) Option

WithURI sets the Thrift URI for the Hive Metastore.

func WithWarehouse

func WithWarehouse(warehouse string) Option

Jump to

Keyboard shortcuts

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