org.apache.hadoop.hive.metastore
Class HiveMetaStoreClient

java.lang.Object
  extended by org.apache.hadoop.hive.metastore.HiveMetaStoreClient
All Implemented Interfaces:
IMetaStoreClient

public class HiveMetaStoreClient
extends Object
implements IMetaStoreClient

Hive Metastore Client.


Constructor Summary
HiveMetaStoreClient(HiveConf conf)
           
 
Method Summary
 Partition add_partition(Partition new_part)
          Add a partition to the table.
 void alter_partition(String dbName, String tblName, Partition newPart)
          updates a partition to new partition
 void alter_table(String dbname, String tbl_name, Table new_tbl)
           
 Partition appendPartition(String db_name, String table_name, List<String> part_vals)
           
 void close()
           
 boolean createDatabase(String name, String location_uri)
           
 void createTable(Table tbl)
           
 boolean createType(Type type)
           
 boolean dropDatabase(String name)
           
 boolean dropPartition(String db_name, String tbl_name, List<String> part_vals)
           
 boolean dropPartition(String db_name, String tbl_name, List<String> part_vals, boolean deleteData)
           
 void dropTable(String tableName, boolean deleteData)
          Drop the table.
 void dropTable(String dbname, String name)
           
 void dropTable(String dbname, String name, boolean deleteData, boolean ignoreUknownTab)
          Drop the table.
 boolean dropType(String type)
           
 Database getDatabase(String name)
           
 List<String> getDatabases()
           
 List<FieldSchema> getFields(String db, String tableName)
           
 Partition getPartition(String db_name, String tbl_name, List<String> part_vals)
           
 List<FieldSchema> getSchema(String db, String tableName)
           
 Table getTable(String tableName)
          Get a table object.
 Table getTable(String dbname, String name)
          Get a table object.
 List<String> getTables(String tablePattern)
           
 List<String> getTables(String dbname, String tablePattern)
           
 Type getType(String name)
           
 Map<String,Type> getTypeAll(String name)
           
 List<String> listPartitionNames(String dbName, String tblName, short max)
           
 List<Partition> listPartitions(String db_name, String tbl_name, short max_parts)
           
 boolean tableExists(String tableName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HiveMetaStoreClient

public HiveMetaStoreClient(HiveConf conf)
                    throws MetaException
Throws:
MetaException
Method Detail

alter_table

public void alter_table(String dbname,
                        String tbl_name,
                        Table new_tbl)
                 throws InvalidOperationException,
                        MetaException,
                        org.apache.thrift.TException
Specified by:
alter_table in interface IMetaStoreClient
Parameters:
dbname -
tbl_name -
new_tbl -
Throws:
InvalidOperationException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.alter_table(java.lang.String, java.lang.String, org.apache.hadoop.hive.metastore.api.Table)

close

public void close()
Specified by:
close in interface IMetaStoreClient

dropTable

public void dropTable(String tableName,
                      boolean deleteData)
               throws MetaException,
                      NoSuchObjectException
Description copied from interface: IMetaStoreClient
Drop the table.

Specified by:
dropTable in interface IMetaStoreClient
Parameters:
tableName - The table to drop
deleteData - Should we delete the underlying data
Throws:
MetaException - Could not drop table properly.
NoSuchObjectException - The table wasn't found.

add_partition

public Partition add_partition(Partition new_part)
                        throws InvalidObjectException,
                               AlreadyExistsException,
                               MetaException,
                               org.apache.thrift.TException
Description copied from interface: IMetaStoreClient
Add a partition to the table.

Specified by:
add_partition in interface IMetaStoreClient
Parameters:
new_part -
Returns:
the added partition
Throws:
InvalidObjectException
AlreadyExistsException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.add_partition(org.apache.hadoop.hive.metastore.api.Partition)

appendPartition

public Partition appendPartition(String db_name,
                                 String table_name,
                                 List<String> part_vals)
                          throws InvalidObjectException,
                                 AlreadyExistsException,
                                 MetaException,
                                 org.apache.thrift.TException
Specified by:
appendPartition in interface IMetaStoreClient
Parameters:
table_name -
db_name -
part_vals -
Returns:
the appended partition
Throws:
InvalidObjectException
AlreadyExistsException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.append_partition(java.lang.String, java.lang.String, java.util.List)

createDatabase

public boolean createDatabase(String name,
                              String location_uri)
                       throws AlreadyExistsException,
                              MetaException,
                              org.apache.thrift.TException
Specified by:
createDatabase in interface IMetaStoreClient
Parameters:
name -
location_uri -
Returns:
true or false
Throws:
AlreadyExistsException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.create_database(java.lang.String, java.lang.String)

createTable

public void createTable(Table tbl)
                 throws AlreadyExistsException,
                        InvalidObjectException,
                        MetaException,
                        NoSuchObjectException,
                        org.apache.thrift.TException
Specified by:
createTable in interface IMetaStoreClient
Parameters:
tbl -
Throws:
MetaException
NoSuchObjectException
org.apache.thrift.TException
AlreadyExistsException
InvalidObjectException
See Also:
ThriftHiveMetastore.Iface.create_table(org.apache.hadoop.hive.metastore.api.Table)

createType

public boolean createType(Type type)
                   throws AlreadyExistsException,
                          InvalidObjectException,
                          MetaException,
                          org.apache.thrift.TException
Parameters:
type -
Returns:
true or false
Throws:
AlreadyExistsException
InvalidObjectException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.create_type(org.apache.hadoop.hive.metastore.api.Type)

dropDatabase

public boolean dropDatabase(String name)
                     throws MetaException,
                            org.apache.thrift.TException
Specified by:
dropDatabase in interface IMetaStoreClient
Parameters:
name -
Returns:
true or false
Throws:
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.drop_database(java.lang.String)

dropPartition

public boolean dropPartition(String db_name,
                             String tbl_name,
                             List<String> part_vals)
                      throws NoSuchObjectException,
                             MetaException,
                             org.apache.thrift.TException
Parameters:
tbl_name -
db_name -
part_vals -
Returns:
true or false
Throws:
NoSuchObjectException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.drop_partition(java.lang.String, java.lang.String, java.util.List, boolean)

dropPartition

public boolean dropPartition(String db_name,
                             String tbl_name,
                             List<String> part_vals,
                             boolean deleteData)
                      throws NoSuchObjectException,
                             MetaException,
                             org.apache.thrift.TException
Specified by:
dropPartition in interface IMetaStoreClient
Parameters:
db_name -
tbl_name -
part_vals -
deleteData - delete the underlying data or just delete the table in metadata
Returns:
true or false
Throws:
NoSuchObjectException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.drop_partition(java.lang.String, java.lang.String, java.util.List, boolean)

dropTable

public void dropTable(String dbname,
                      String name)
               throws NoSuchObjectException,
                      MetaException,
                      org.apache.thrift.TException
Parameters:
name -
dbname -
Throws:
NoSuchObjectException
ExistingDependentsException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.drop_table(java.lang.String, java.lang.String, boolean)

dropTable

public void dropTable(String dbname,
                      String name,
                      boolean deleteData,
                      boolean ignoreUknownTab)
               throws MetaException,
                      org.apache.thrift.TException,
                      NoSuchObjectException
Description copied from interface: IMetaStoreClient
Drop the table.

Specified by:
dropTable in interface IMetaStoreClient
Parameters:
dbname -
name -
deleteData - delete the underlying data or just delete the table in metadata
Throws:
NoSuchObjectException
ExistingDependentsException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.drop_table(java.lang.String, java.lang.String, boolean)

dropType

public boolean dropType(String type)
                 throws MetaException,
                        org.apache.thrift.TException
Parameters:
type -
Returns:
true if the type is dropped
Throws:
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.drop_type(java.lang.String)

getTypeAll

public Map<String,Type> getTypeAll(String name)
                            throws MetaException,
                                   org.apache.thrift.TException
Parameters:
name -
Returns:
map of types
Throws:
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.get_type_all(java.lang.String)

getDatabases

public List<String> getDatabases()
                          throws MetaException,
                                 org.apache.thrift.TException
Returns:
the list of databases
Throws:
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.get_databases()

listPartitions

public List<Partition> listPartitions(String db_name,
                                      String tbl_name,
                                      short max_parts)
                               throws NoSuchObjectException,
                                      MetaException,
                                      org.apache.thrift.TException
Specified by:
listPartitions in interface IMetaStoreClient
Parameters:
tbl_name -
db_name -
max_parts -
Returns:
list of partitions
Throws:
NoSuchObjectException
MetaException
org.apache.thrift.TException

getDatabase

public Database getDatabase(String name)
                     throws NoSuchObjectException,
                            MetaException,
                            org.apache.thrift.TException
Parameters:
name -
Returns:
the database
Throws:
NoSuchObjectException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.get_database(java.lang.String)

getPartition

public Partition getPartition(String db_name,
                              String tbl_name,
                              List<String> part_vals)
                       throws MetaException,
                              org.apache.thrift.TException
Specified by:
getPartition in interface IMetaStoreClient
Parameters:
tbl_name -
db_name -
part_vals -
Returns:
the partition
Throws:
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.get_partition(java.lang.String, java.lang.String, java.util.List)

getTable

public Table getTable(String dbname,
                      String name)
               throws MetaException,
                      org.apache.thrift.TException,
                      NoSuchObjectException
Description copied from interface: IMetaStoreClient
Get a table object.

Specified by:
getTable in interface IMetaStoreClient
Parameters:
name -
dbname -
Returns:
the table
Throws:
NoSuchObjectException
MetaException
org.apache.thrift.TException
NoSuchObjectException
See Also:
ThriftHiveMetastore.Iface.get_table(java.lang.String, java.lang.String)

getType

public Type getType(String name)
             throws MetaException,
                    org.apache.thrift.TException
Parameters:
name -
Returns:
the type
Throws:
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.get_type(java.lang.String)

getTables

public List<String> getTables(String dbname,
                              String tablePattern)
                       throws MetaException
Specified by:
getTables in interface IMetaStoreClient
Throws:
MetaException

getTables

public List<String> getTables(String tablePattern)
                       throws MetaException
Throws:
MetaException

tableExists

public boolean tableExists(String tableName)
                    throws MetaException,
                           org.apache.thrift.TException,
                           UnknownDBException
Specified by:
tableExists in interface IMetaStoreClient
Throws:
MetaException
org.apache.thrift.TException
UnknownDBException

getTable

public Table getTable(String tableName)
               throws MetaException,
                      org.apache.thrift.TException,
                      NoSuchObjectException
Description copied from interface: IMetaStoreClient
Get a table object.

Specified by:
getTable in interface IMetaStoreClient
Parameters:
tableName - Name of the table to fetch.
Returns:
An object representing the table.
Throws:
MetaException - Could not fetch the table
org.apache.thrift.TException - A thrift communication error occurred
NoSuchObjectException - In case the table wasn't found.

listPartitionNames

public List<String> listPartitionNames(String dbName,
                                       String tblName,
                                       short max)
                                throws MetaException,
                                       org.apache.thrift.TException
Specified by:
listPartitionNames in interface IMetaStoreClient
Throws:
MetaException
org.apache.thrift.TException

alter_partition

public void alter_partition(String dbName,
                            String tblName,
                            Partition newPart)
                     throws InvalidOperationException,
                            MetaException,
                            org.apache.thrift.TException
Description copied from interface: IMetaStoreClient
updates a partition to new partition

Specified by:
alter_partition in interface IMetaStoreClient
Parameters:
dbName - database of the old partition
tblName - table name of the old partition
newPart - new partition
Throws:
InvalidOperationException - if the old partition does not exist
MetaException - if error in updating metadata
org.apache.thrift.TException - if error in communicating with metastore server

getFields

public List<FieldSchema> getFields(String db,
                                   String tableName)
                            throws MetaException,
                                   org.apache.thrift.TException,
                                   UnknownTableException,
                                   UnknownDBException
Specified by:
getFields in interface IMetaStoreClient
Parameters:
db -
tableName -
Throws:
UnknownTableException
UnknownDBException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.get_fields(java.lang.String, java.lang.String)

getSchema

public List<FieldSchema> getSchema(String db,
                                   String tableName)
                            throws MetaException,
                                   org.apache.thrift.TException,
                                   UnknownTableException,
                                   UnknownDBException
Specified by:
getSchema in interface IMetaStoreClient
Parameters:
db -
tableName -
Throws:
UnknownTableException
UnknownDBException
MetaException
org.apache.thrift.TException
See Also:
ThriftHiveMetastore.Iface.get_schema(java.lang.String, java.lang.String)


Copyright © 2009 The Apache Software Foundation