package catalog
import (
"context"
"errors"
"github.com/polarsignals/iceberg-go"
"github.com/polarsignals/iceberg-go/table"
)
type CatalogType string
const (
REST CatalogType = "rest"
Hive CatalogType = "hive"
Glue CatalogType = "glue"
DynamoDB CatalogType = "dynamodb"
SQL CatalogType = "sql"
Hadoop CatalogType = "hadoop"
)
var (
ErrNoSuchTable = errors .New ("table does not exist" )
ErrNoSuchNamespace = errors .New ("namespace does not exist" )
ErrNamespaceAlreadyExists = errors .New ("namespace already exists" )
)
type PropertiesUpdateSummary struct {
Removed []string `json:"removed"`
Updated []string `json:"updated"`
Missing []string `json:"missing"`
}
type Catalog interface {
CatalogType () CatalogType
ListTables (ctx context .Context , namespace table .Identifier ) ([]table .Identifier , error )
LoadTable (ctx context .Context , identifier table .Identifier , props iceberg .Properties ) (table .Table , error )
DropTable (ctx context .Context , identifier table .Identifier ) error
RenameTable (ctx context .Context , from, to table .Identifier ) (table .Table , error )
ListNamespaces (ctx context .Context , parent table .Identifier ) ([]table .Identifier , error )
CreateNamespace (ctx context .Context , namespace table .Identifier , props iceberg .Properties ) error
DropNamespace (ctx context .Context , namespace table .Identifier ) error
LoadNamespaceProperties (ctx context .Context , namespace table .Identifier ) (iceberg .Properties , error )
UpdateNamespaceProperties (ctx context .Context , namespace table .Identifier ,
removals []string , updates iceberg .Properties ) (PropertiesUpdateSummary , error )
CreateTable (ctx context .Context , location string , schema *iceberg .Schema , props iceberg .Properties , options ...TableOption ) (table .Table , error )
}
type TableOption func (*tableOptions )
type tableOptions struct {
partitionSpec iceberg .PartitionSpec
}
func WithPartitionSpec (spec iceberg .PartitionSpec ) TableOption {
return func (opts *tableOptions ) {
opts .partitionSpec = spec
}
}
const (
keyOauthToken = "token"
keyWarehouseLocation = "warehouse"
keyMetadataLocation = "metadata_location"
keyOauthCredential = "credential"
)
func TableNameFromIdent (ident table .Identifier ) string {
if len (ident ) == 0 {
return ""
}
return ident [len (ident )-1 ]
}
func NamespaceFromIdent (ident table .Identifier ) table .Identifier {
return ident [:len (ident )-1 ]
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .