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)
           
HiveMetaStoreClient(HiveConf conf, HiveMetaHookLoader hookLoader)
           
 
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)
           
 Partition appendPartition(String dbName, String tableName, String partName)
           
 Partition appendPartitionByName(String dbName, String tableName, String partName)
           
 void close()
           
 void createDatabase(Database db)
          Create a new Database
 void createTable(Table tbl)
           
 boolean createType(Type type)
           
 void dropDatabase(String name)
           
 void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb)
           
 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)
           
 boolean dropPartition(String dbName, String tableName, String partName, boolean deleteData)
           
 boolean dropPartitionByName(String dbName, String tableName, String partName, boolean deleteData)
           
 void dropTable(String tableName, boolean deleteData)
          Deprecated. 
 void dropTable(String dbname, String name)
           
 void dropTable(String dbname, String name, boolean deleteData, boolean ignoreUknownTab)
          Drop the table.
 boolean dropType(String type)
           
 List<String> getAllDatabases()
          Get the names of all databases in the MetaStore.
 List<String> getAllTables(String dbname)
          Get the names of all tables in the specified database.
 String getConfigValue(String name, String defaultValue)
           
 Database getDatabase(String name)
          Get a Database Object
 List<String> getDatabases(String databasePattern)
          Get the names of all databases in the MetaStore that match the given pattern.
 List<FieldSchema> getFields(String db, String tableName)
           
 Partition getPartition(String db_name, String tbl_name, List<String> part_vals)
           
 Partition getPartition(String db, String tableName, String partName)
           
 List<FieldSchema> getSchema(String db, String tableName)
           
 Table getTable(String tableName)
          Deprecated. 
 Table getTable(String dbname, String name)
          Get a table object.
 List<String> getTables(String dbname, String tablePattern)
          Get the names of all tables in the specified database that satisfy the supplied table name pattern.
 Type getType(String name)
           
 Map<String,Type> getTypeAll(String name)
           
 List<String> listPartitionNames(String db_name, String tbl_name, List<String> part_vals, short max_parts)
           
 List<String> listPartitionNames(String dbName, String tblName, short max)
           
 List<Partition> listPartitions(String db_name, String tbl_name, List<String> part_vals, short max_parts)
           
 List<Partition> listPartitions(String db_name, String tbl_name, short max_parts)
           
 Map<String,String> partitionNameToSpec(String name)
           
 List<String> partitionNameToVals(String name)
           
 boolean tableExists(String tableName)
          Deprecated. 
 boolean tableExists(String databaseName, 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

HiveMetaStoreClient

public HiveMetaStoreClient(HiveConf conf,
                           HiveMetaHookLoader hookLoader)
                    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

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)

appendPartition

public Partition appendPartition(String dbName,
                                 String tableName,
                                 String partName)
                          throws InvalidObjectException,
                                 AlreadyExistsException,
                                 MetaException,
                                 org.apache.thrift.TException
Specified by:
appendPartition in interface IMetaStoreClient
Throws:
InvalidObjectException
AlreadyExistsException
MetaException
org.apache.thrift.TException

createDatabase

public void createDatabase(Database db)
                    throws AlreadyExistsException,
                           InvalidObjectException,
                           MetaException,
                           org.apache.thrift.TException
Create a new Database

Specified by:
createDatabase in interface IMetaStoreClient
Parameters:
db -
Throws:
AlreadyExistsException
InvalidObjectException
MetaException
org.apache.thrift.TException
See Also:
org.apache.hadoop.hive.metastore.api.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 void dropDatabase(String name)
                  throws NoSuchObjectException,
                         InvalidOperationException,
                         MetaException,
                         org.apache.thrift.TException
Specified by:
dropDatabase in interface IMetaStoreClient
Parameters:
name -
Throws:
NoSuchObjectException
InvalidOperationException
MetaException
org.apache.thrift.TException
See Also:
org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#drop_database(java.lang.String)

dropDatabase

public void dropDatabase(String name,
                         boolean deleteData,
                         boolean ignoreUnknownDb)
                  throws NoSuchObjectException,
                         InvalidOperationException,
                         MetaException,
                         org.apache.thrift.TException
Specified by:
dropDatabase in interface IMetaStoreClient
Throws:
NoSuchObjectException
InvalidOperationException
MetaException
org.apache.thrift.TException

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 dbName,
                             String tableName,
                             String partName,
                             boolean deleteData)
                      throws NoSuchObjectException,
                             MetaException,
                             org.apache.thrift.TException
Specified by:
dropPartition in interface IMetaStoreClient
Throws:
NoSuchObjectException
MetaException
org.apache.thrift.TException

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
Specified by:
dropTable in interface IMetaStoreClient
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

@Deprecated
public void dropTable(String tableName,
                                 boolean deleteData)
               throws MetaException,
                      UnknownTableException,
                      org.apache.thrift.TException,
                      NoSuchObjectException
Deprecated. 

Drop the table in the DEFAULT database.

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.
UnknownTableException - The table wasn't found.
org.apache.thrift.TException - A thrift communication error occurred
NoSuchObjectException - The table wasn't found.

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,
                        NoSuchObjectException,
                        org.apache.thrift.TException
Parameters:
type -
Returns:
true if the type is dropped
Throws:
MetaException
NoSuchObjectException
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(String databasePattern)
                          throws MetaException
Get the names of all databases in the MetaStore that match the given pattern.

Specified by:
getDatabases in interface IMetaStoreClient
Returns:
List of database names.
Throws:
MetaException

getAllDatabases

public List<String> getAllDatabases()
                             throws MetaException
Get the names of all databases in the MetaStore.

Specified by:
getAllDatabases in interface IMetaStoreClient
Returns:
List of database names.
Throws:
MetaException

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

listPartitions

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

getDatabase

public Database getDatabase(String name)
                     throws NoSuchObjectException,
                            MetaException,
                            org.apache.thrift.TException
Description copied from interface: IMetaStoreClient
Get a Database Object

Specified by:
getDatabase in interface IMetaStoreClient
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 NoSuchObjectException,
                              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
NoSuchObjectException
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)

getTable

@Deprecated
public Table getTable(String tableName)
               throws MetaException,
                      org.apache.thrift.TException,
                      NoSuchObjectException
Deprecated. 

Get a table object from the DEFAULT database.

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.

getType

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

getTables

public List<String> getTables(String dbname,
                              String tablePattern)
                       throws MetaException
Get the names of all tables in the specified database that satisfy the supplied table name pattern.

Specified by:
getTables in interface IMetaStoreClient
Returns:
List of table names.
Throws:
MetaException

getAllTables

public List<String> getAllTables(String dbname)
                          throws MetaException
Get the names of all tables in the specified database.

Specified by:
getAllTables in interface IMetaStoreClient
Returns:
List of table names.
Throws:
MetaException

tableExists

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

tableExists

@Deprecated
public boolean tableExists(String tableName)
                    throws MetaException,
                           org.apache.thrift.TException,
                           UnknownDBException
Deprecated. 

Check to see if the specified table exists in the DEFAULT database.

Specified by:
tableExists in interface IMetaStoreClient
Returns:
TRUE if DEFAULT.tableName exists, FALSE otherwise.
Throws:
MetaException
org.apache.thrift.TException
UnknownDBException

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

listPartitionNames

public List<String> listPartitionNames(String db_name,
                                       String tbl_name,
                                       List<String> part_vals,
                                       short max_parts)
                                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)

getConfigValue

public String getConfigValue(String name,
                             String defaultValue)
                      throws org.apache.thrift.TException,
                             ConfigValSecurityException
Specified by:
getConfigValue in interface IMetaStoreClient
Parameters:
name - name of the configuration property to get the value of
defaultValue - the value to return if property with the given name doesn't exist
Returns:
value of the specified configuration property
Throws:
org.apache.thrift.TException
ConfigValSecurityException

getPartition

public Partition getPartition(String db,
                              String tableName,
                              String partName)
                       throws MetaException,
                              org.apache.thrift.TException,
                              UnknownTableException,
                              NoSuchObjectException
Specified by:
getPartition in interface IMetaStoreClient
partName - - partition name i.e. 'ds=2010-02-03/ts=2010-02-03 18%3A16%3A01'
Returns:
the partition object
Throws:
MetaException
org.apache.thrift.TException
UnknownTableException
NoSuchObjectException
See Also:
ThriftHiveMetastore.Iface.get_partition(java.lang.String, java.lang.String, java.util.List)

appendPartitionByName

public Partition appendPartitionByName(String dbName,
                                       String tableName,
                                       String partName)
                                throws InvalidObjectException,
                                       AlreadyExistsException,
                                       MetaException,
                                       org.apache.thrift.TException
Throws:
InvalidObjectException
AlreadyExistsException
MetaException
org.apache.thrift.TException

dropPartitionByName

public boolean dropPartitionByName(String dbName,
                                   String tableName,
                                   String partName,
                                   boolean deleteData)
                            throws NoSuchObjectException,
                                   MetaException,
                                   org.apache.thrift.TException
Throws:
NoSuchObjectException
MetaException
org.apache.thrift.TException

partitionNameToVals

public List<String> partitionNameToVals(String name)
                                 throws MetaException,
                                        org.apache.thrift.TException
Specified by:
partitionNameToVals in interface IMetaStoreClient
Parameters:
name - the partition name e.g. ("ds=2010-03-03/hr=12")
Returns:
a list containing the partition col values, in the same order as the name
Throws:
MetaException
org.apache.thrift.TException

partitionNameToSpec

public Map<String,String> partitionNameToSpec(String name)
                                       throws MetaException,
                                              org.apache.thrift.TException
Specified by:
partitionNameToSpec in interface IMetaStoreClient
Parameters:
name - the partition name e.g. ("ds=2010-03-03/hr=12")
Returns:
a map from the partition col to the value, as listed in the name
Throws:
MetaException
org.apache.thrift.TException


Copyright © 2010 The Apache Software Foundation