Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "fmt" "log" "github.com/jahnestacado/gometastore" ) func main() { client, err := gometastore.Open("localhost", 9083, nil) if err != nil { log.Fatal(err) } fmt.Println(client.GetAllDatabases(context.Background())) }
Output:
Index ¶
- func MakePartition(table *hive_metastore.Table, values []string, parameters map[string]string, ...) (*hive_metastore.Partition, error)
- type Database
- type MetastoreClient
- func (c *MetastoreClient) AddPartition(ctx context.Context, partition *hive_metastore.Partition) (*hive_metastore.Partition, error)
- func (c *MetastoreClient) AddPartitions(ctx context.Context, newParts []*hive_metastore.Partition) error
- func (c *MetastoreClient) AlterTable(ctx context.Context, dbName string, tableName string, ...) error
- func (c *MetastoreClient) Clone() (client *MetastoreClient, err error)
- func (c *MetastoreClient) Close()
- func (c *MetastoreClient) CreateDatabase(ctx context.Context, db *Database) error
- func (c *MetastoreClient) CreateTable(ctx context.Context, table *hive_metastore.Table) error
- func (c *MetastoreClient) DropDatabase(ctx context.Context, dbName string, deleteData bool, cascade bool) error
- func (c *MetastoreClient) DropPartition(ctx context.Context, dbName string, tableName string, values []string, ...) (bool, error)
- func (c *MetastoreClient) DropPartitionByName(ctx context.Context, dbName string, tableName string, partName string, ...) (bool, error)
- func (c *MetastoreClient) DropPartitions(ctx context.Context, dbName string, tableName string, partNames []string) error
- func (c *MetastoreClient) DropTable(ctx context.Context, dbName string, tableName string, deleteData bool) error
- func (c *MetastoreClient) GetAllDatabases(ctx context.Context) ([]string, error)
- func (c *MetastoreClient) GetAllTables(ctx context.Context, dbName string) ([]string, error)
- func (c *MetastoreClient) GetCurrentNotificationId(ctx context.Context) (int64, error)
- func (c *MetastoreClient) GetDatabase(ctx context.Context, dbName string) (*Database, error)
- func (c *MetastoreClient) GetDatabases(ctx context.Context, pattern string) ([]string, error)
- func (c *MetastoreClient) GetNextNotification(ctx context.Context, lastEvent int64, maxEvents int32) ([]*hive_metastore.NotificationEvent, error)
- func (c *MetastoreClient) GetPartitionByName(ctx context.Context, dbName string, tableName string, partName string) (*hive_metastore.Partition, error)
- func (c *MetastoreClient) GetPartitionNames(ctx context.Context, dbName string, tableName string, max int) ([]string, error)
- func (c *MetastoreClient) GetPartitions(ctx context.Context, dbName string, tableName string, maxCount int) ([]*hive_metastore.Partition, error)
- func (c *MetastoreClient) GetPartitionsByNames(ctx context.Context, dbName string, tableName string, partNames []string) ([]*hive_metastore.Partition, error)
- func (c *MetastoreClient) GetTable(ctx context.Context, dbName string, tableName string) (*hive_metastore.Table, error)
- func (c *MetastoreClient) GetTableMeta(ctx context.Context, db string, table string, tableTypes []string) ([]*hive_metastore.TableMeta, error)
- func (c *MetastoreClient) GetTableObjects(ctx context.Context, dbName string, tableNames []string) ([]*hive_metastore.Table, error)
- func (c *MetastoreClient) GetTables(ctx context.Context, dbName string, pattern string) ([]string, error)
- func (c *MetastoreClient) GetTablesByType(ctx context.Context, dbName string, table string, tableType string) ([]string, error)
- type Options
- type PartitionBuilder
- func (p *PartitionBuilder) Build() *hive_metastore.Partition
- func (pb *PartitionBuilder) WithLocation(location string) *PartitionBuilder
- func (pb *PartitionBuilder) WithParameter(key string, value string) *PartitionBuilder
- func (pb *PartitionBuilder) WithParameters(parameters map[string]string) *PartitionBuilder
- type TableBuilder
- func (tb *TableBuilder) AsExternal() *TableBuilder
- func (tb *TableBuilder) Build() *hive_metastore.Table
- func (tb *TableBuilder) WithColumns(columns []hive_metastore.FieldSchema) *TableBuilder
- func (tb *TableBuilder) WithInputFormat(format string) *TableBuilder
- func (tb *TableBuilder) WithLocation(location string) *TableBuilder
- func (tb *TableBuilder) WithOutputFormat(format string) *TableBuilder
- func (tb *TableBuilder) WithOwner(owner string) *TableBuilder
- func (tb *TableBuilder) WithParameter(name string, value string) *TableBuilder
- func (tb *TableBuilder) WithParameters(parameters map[string]string) *TableBuilder
- func (tb *TableBuilder) WithPartitionKeys(partKeys []hive_metastore.FieldSchema) *TableBuilder
- func (tb *TableBuilder) WithSerde(serde string) *TableBuilder
- func (tb *TableBuilder) WithType(t TableType) *TableBuilder
- type TableType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakePartition ¶
func MakePartition(table *hive_metastore.Table, values []string, parameters map[string]string, location string) (*hive_metastore.Partition, error)
MakePartition creates Partition object from ordered list of partition values. Only string values are currently supported. Parameters:
table - Hive table for which partition is added values - List of partition values which should match partition schema
Types ¶
type Database ¶
type Database struct { Name string `json:"name"` Description string `json:"description,omitempty"` Owner string `json:"owner,omitempty"` OwnerType hive_metastore.PrincipalType `json:"ownerType,omitempty"` Location string `json:"location"` Parameters map[string]string `json:"parameters,omitempty"` }
Database is a container of other objects in Hive.
type MetastoreClient ¶
type MetastoreClient struct {
// contains filtered or unexported fields
}
MetastoreClient represents client handle.
func Open ¶
func Open(host string, port int, options *Options) (*MetastoreClient, error)
Open connection to metastore and return client handle.
Example ¶
package main import ( "context" "fmt" "log" "github.com/jahnestacado/gometastore" ) func main() { client, err := gometastore.Open("localhost", 9083, nil) if err != nil { log.Fatal(err) } fmt.Println(client.GetAllDatabases(context.Background())) }
Output:
func (*MetastoreClient) AddPartition ¶
func (c *MetastoreClient) AddPartition(ctx context.Context, partition *hive_metastore.Partition) (*hive_metastore.Partition, error)
AddPartition adds partition to Hive table.
func (*MetastoreClient) AddPartitions ¶
func (c *MetastoreClient) AddPartitions(ctx context.Context, newParts []*hive_metastore.Partition) error
AddPartitions adds multipe partitions in a single call.
func (*MetastoreClient) AlterTable ¶
func (c *MetastoreClient) AlterTable(ctx context.Context, dbName string, tableName string, table *hive_metastore.Table) error
AlterTable modifies existing table with data from the new table
func (*MetastoreClient) Clone ¶
func (c *MetastoreClient) Clone() (client *MetastoreClient, err error)
Clone metastore client and return a new client with its own connection to metastore.
func (*MetastoreClient) Close ¶
func (c *MetastoreClient) Close()
Close connection to metastore. Handle can't be used once it is closed.
func (*MetastoreClient) CreateDatabase ¶
func (c *MetastoreClient) CreateDatabase(ctx context.Context, db *Database) error
CreateDatabase creates database with the specified name, description, parameters and owner.
func (*MetastoreClient) CreateTable ¶
func (c *MetastoreClient) CreateTable(ctx context.Context, table *hive_metastore.Table) error
CreateTable Creates HMS table
func (*MetastoreClient) DropDatabase ¶
func (c *MetastoreClient) DropDatabase(ctx context.Context, dbName string, deleteData bool, cascade bool) error
DropDatabases removes the database specified by name Parameters:
dbName - database name deleteData - if true, delete data as well cascade - delete everything under the db if true
func (*MetastoreClient) DropPartition ¶
func (c *MetastoreClient) DropPartition(ctx context.Context, dbName string, tableName string, values []string, dropData bool) (bool, error)
DropPartition drops partition specified by values.
func (*MetastoreClient) DropPartitionByName ¶
func (c *MetastoreClient) DropPartitionByName(ctx context.Context, dbName string, tableName string, partName string, dropData bool) (bool, error)
DropPartitionByName drops partition specified by name.
func (*MetastoreClient) DropPartitions ¶
func (c *MetastoreClient) DropPartitions(ctx context.Context, dbName string, tableName string, partNames []string) error
DropPartitions drops multiple partitions within a single table. Partitions are specified by names.
func (*MetastoreClient) DropTable ¶
func (c *MetastoreClient) DropTable(ctx context.Context, dbName string, tableName string, deleteData bool) error
DropTable drops table. Parameters
dbName - Database name tableName - Table name deleteData - if True, delete data as well
func (*MetastoreClient) GetAllDatabases ¶
func (c *MetastoreClient) GetAllDatabases(ctx context.Context) ([]string, error)
GetAllDatabases returns list of all Hive databases.
Example ¶
package main import ( "context" "fmt" "log" "github.com/jahnestacado/gometastore" ) func main() { client, err := gometastore.Open("localhost", 9083, nil) if err != nil { log.Fatal(err) } defer client.Close() fmt.Println(client.GetAllDatabases(context.Background())) }
Output:
func (*MetastoreClient) GetAllTables ¶
GetAllTables returns list of all table names for a given database
func (*MetastoreClient) GetCurrentNotificationId ¶
func (c *MetastoreClient) GetCurrentNotificationId(ctx context.Context) (int64, error)
GetCurrentNotificationId returns value of last notification ID
func (*MetastoreClient) GetDatabase ¶
GetDatabase returns detailed information about specified Hive database.
func (*MetastoreClient) GetDatabases ¶
GetDatabases returns list of all databases matching pattern. The pattern is interpreted by HMS.
func (*MetastoreClient) GetNextNotification ¶
func (c *MetastoreClient) GetNextNotification(ctx context.Context, lastEvent int64, maxEvents int32) ([]*hive_metastore.NotificationEvent, error)
GetNextNotification returns next available notification.
func (*MetastoreClient) GetPartitionByName ¶
func (c *MetastoreClient) GetPartitionByName(ctx context.Context, dbName string, tableName string, partName string) (*hive_metastore.Partition, error)
GetPartitionByName returns Partition for the given partition name.
func (*MetastoreClient) GetPartitionNames ¶
func (c *MetastoreClient) GetPartitionNames(ctx context.Context, dbName string, tableName string, max int) ([]string, error)
GetPartitionNames returns list of partition names for a table.
func (*MetastoreClient) GetPartitions ¶
func (c *MetastoreClient) GetPartitions(ctx context.Context, dbName string, tableName string, maxCount int) ([]*hive_metastore.Partition, error)
GetPartitions returns all (or up to maxCount partitions of a table.
func (*MetastoreClient) GetPartitionsByNames ¶
func (c *MetastoreClient) GetPartitionsByNames(ctx context.Context, dbName string, tableName string, partNames []string) ([]*hive_metastore.Partition, error)
GetPartitionsByNames returns multiple partitions specified by names.
func (*MetastoreClient) GetTable ¶
func (c *MetastoreClient) GetTable(ctx context.Context, dbName string, tableName string) (*hive_metastore.Table, error)
GetTable returns detailed information about the specified table
func (*MetastoreClient) GetTableMeta ¶
func (c *MetastoreClient) GetTableMeta(ctx context.Context, db string, table string, tableTypes []string) ([]*hive_metastore.TableMeta, error)
GetTableMeta returns list of tables matching specified search criteria. Parameters:
db - database name pattern table - table name pattern tableTypes - list of Table types - should be either TABLE or VIEW
func (*MetastoreClient) GetTableObjects ¶
func (c *MetastoreClient) GetTableObjects(ctx context.Context, dbName string, tableNames []string) ([]*hive_metastore.Table, error)
GetTableObjects returns list of Table objects for the given database and list of table names.
func (*MetastoreClient) GetTables ¶
func (c *MetastoreClient) GetTables(ctx context.Context, dbName string, pattern string) ([]string, error)
GetTables returns list of tables matching given pattern for the given database. Matching is performed on the server side.
func (*MetastoreClient) GetTablesByType ¶
func (c *MetastoreClient) GetTablesByType(ctx context.Context, dbName string, table string, tableType string) ([]string, error)
GetTablesByType returns list of tables matching specified search criteria. Parameters:
dbName - database name table - table name pattern tableType - Table type - should be either TABLE or VIEW
type PartitionBuilder ¶
type PartitionBuilder struct { Table *hive_metastore.Table Parameters map[string]string Values []string Location string }
func NewPartitionBuilder ¶
func NewPartitionBuilder(table *hive_metastore.Table, values []string) (*PartitionBuilder, error)
func (*PartitionBuilder) Build ¶
func (p *PartitionBuilder) Build() *hive_metastore.Partition
func (*PartitionBuilder) WithLocation ¶
func (pb *PartitionBuilder) WithLocation(location string) *PartitionBuilder
func (*PartitionBuilder) WithParameter ¶
func (pb *PartitionBuilder) WithParameter(key string, value string) *PartitionBuilder
func (*PartitionBuilder) WithParameters ¶
func (pb *PartitionBuilder) WithParameters(parameters map[string]string) *PartitionBuilder
type TableBuilder ¶
type TableBuilder struct { Db string Name string Type TableType Serde string Owner string InputFormat string OutputFormat string Location string Columns []hive_metastore.FieldSchema PartitionKeys []hive_metastore.FieldSchema Parameters map[string]string }
TableBuilder provides builder pattern for table objects
func NewTableBuilder ¶
func NewTableBuilder(db string, tableName string) *TableBuilder
func (*TableBuilder) AsExternal ¶
func (tb *TableBuilder) AsExternal() *TableBuilder
Mark table as external
func (*TableBuilder) Build ¶
func (tb *TableBuilder) Build() *hive_metastore.Table
Build HMS Table object.
func (*TableBuilder) WithColumns ¶
func (tb *TableBuilder) WithColumns(columns []hive_metastore.FieldSchema) *TableBuilder
WithColumns specifies table columns
func (*TableBuilder) WithInputFormat ¶
func (tb *TableBuilder) WithInputFormat(format string) *TableBuilder
WithInputFormat specifies table input format
func (*TableBuilder) WithLocation ¶
func (tb *TableBuilder) WithLocation(location string) *TableBuilder
WithLocation specifies table location
func (*TableBuilder) WithOutputFormat ¶
func (tb *TableBuilder) WithOutputFormat(format string) *TableBuilder
WithOutputFormat specifies table output format
func (*TableBuilder) WithOwner ¶
func (tb *TableBuilder) WithOwner(owner string) *TableBuilder
WithOwner specifies table owner
func (*TableBuilder) WithParameter ¶
func (tb *TableBuilder) WithParameter(name string, value string) *TableBuilder
WithParameter adds table parameter
func (*TableBuilder) WithParameters ¶
func (tb *TableBuilder) WithParameters(parameters map[string]string) *TableBuilder
WithParameters specifies table parameters
func (*TableBuilder) WithPartitionKeys ¶
func (tb *TableBuilder) WithPartitionKeys(partKeys []hive_metastore.FieldSchema) *TableBuilder
WithPartitionKeys specifies table partition keys
func (*TableBuilder) WithSerde ¶
func (tb *TableBuilder) WithSerde(serde string) *TableBuilder
WithSerde specifies table serde
func (*TableBuilder) WithType ¶
func (tb *TableBuilder) WithType(t TableType) *TableBuilder
WithType specifies table type
Directories ¶
Path | Synopsis |
---|---|
thrift
|
|
gen-go/hive_metastore
Package hive_metastore provides raw access to HMS Thrift API.
|
Package hive_metastore provides raw access to HMS Thrift API. |