org.apache.hadoop.hive.ql.metadata
Class Hive

java.lang.Object
  extended by org.apache.hadoop.hive.ql.metadata.Hive

public class Hive
extends Object

This class has functions that implement meta data/DDL operations using calls to the metastore. It has a metastore client instance it uses to communicate with the metastore. It is a thread local variable, and the instances is accessed using static get methods in this class.


Method Summary
 void alterDatabase(String dbName, org.apache.hadoop.hive.metastore.api.Database db)
           
 void alterFunction(String dbName, String funcName, org.apache.hadoop.hive.metastore.api.Function newFunction)
           
 void alterIndex(String dbName, String baseTblName, String idxName, org.apache.hadoop.hive.metastore.api.Index newIdx)
          Updates the existing index metadata with the new metadata.
 void alterPartition(String tblName, Partition newPart)
          Updates the existing partition metadata with the new metadata.
 void alterPartition(String dbName, String tblName, Partition newPart)
          Updates the existing partition metadata with the new metadata.
 void alterPartitions(String tblName, List<Partition> newParts)
          Updates the existing table metadata with the new metadata.
 void alterTable(String tblName, Table newTbl)
          Updates the existing table metadata with the new metadata.
 void cancelDelegationToken(String tokenStrForm)
           
static void closeCurrent()
           
 void compact(String dbname, String tableName, String partName, String compactType)
          Enqueue a compaction request.
 void createDatabase(org.apache.hadoop.hive.metastore.api.Database db)
          Create a Database.
 void createDatabase(org.apache.hadoop.hive.metastore.api.Database db, boolean ifNotExist)
          Create a database
 void createFunction(org.apache.hadoop.hive.metastore.api.Function func)
           
 void createIndex(String tableName, String indexName, String indexHandlerClass, List<String> indexedCols, String indexTblName, boolean deferredRebuild, String inputFormat, String outputFormat, String serde, String storageHandler, String location, Map<String,String> idxProps, Map<String,String> tblProps, Map<String,String> serdeProps, String collItemDelim, String fieldDelim, String fieldEscape, String lineDelim, String mapKeyDelim, String indexComment)
           
 Partition createPartition(Table tbl, Map<String,String> partSpec)
          Creates a partition.
 List<Partition> createPartitions(AddPartitionDesc addPartitionDesc)
           
 void createRole(String roleName, String ownerName)
           
 void createTable(String tableName, List<String> columns, List<String> partCols, Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat, Class<?> fileOutputFormat)
          Creates a table metdata and the directory for the table data
 void createTable(String tableName, List<String> columns, List<String> partCols, Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat, Class<?> fileOutputFormat, int bucketCount, List<String> bucketCols)
          Creates a table metdata and the directory for the table data
 void createTable(Table tbl)
          Creates the table with the give objects
 void createTable(Table tbl, boolean ifNotExists)
          Creates the table with the give objects
 boolean databaseExists(String dbName)
          Query metadata to see if a database with the given name already exists.
 boolean deletePartitionColumnStatistics(String dbName, String tableName, String partName, String colName)
           
 boolean deleteTableColumnStatistics(String dbName, String tableName, String colName)
           
 void dropDatabase(String name)
          Drop a database.
 void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb)
          Drop a database
 void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb, boolean cascade)
          Drop a database
 void dropFunction(String dbName, String funcName)
           
 boolean dropIndex(String db_name, String tbl_name, String index_name, boolean deleteData)
           
 boolean dropPartition(String tblName, List<String> part_vals, boolean deleteData)
           
 boolean dropPartition(String db_name, String tbl_name, List<String> part_vals, boolean deleteData)
           
 List<Partition> dropPartitions(String tblName, List<DropTableDesc.PartSpec> partSpecs, boolean deleteData, boolean ignoreProtection, boolean ifExists)
           
 List<Partition> dropPartitions(String dbName, String tblName, List<DropTableDesc.PartSpec> partSpecs, boolean deleteData, boolean ignoreProtection, boolean ifExists)
           
 void dropRole(String roleName)
           
 void dropTable(String tableName)
          Drops table along with the data in it.
 void dropTable(String dbName, String tableName)
          Drops table along with the data in it.
 void dropTable(String dbName, String tableName, boolean deleteData, boolean ignoreUnknownTab)
          Drops the table.
 void exchangeTablePartitions(Map<String,String> partitionSpecs, String sourceDb, String sourceTable, String destDb, String destinationTableName)
           
 org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet get_privilege_set(org.apache.hadoop.hive.metastore.api.HiveObjectType objectType, String db_name, String table_name, List<String> part_values, String column_name, String user_name, List<String> group_names)
           
static Hive get()
           
static Hive get(HiveConf c)
          Gets hive object for the current thread.
static Hive get(HiveConf c, boolean needsRefresh)
          get a connection to metastore.
 List<String> getAllDatabases()
          Get all existing database names.
 Set<Partition> getAllPartitionsOf(Table tbl)
          Get all the partitions; unlike getPartitions(Table), does not include auth.
 List<String> getAllRoleNames()
          Get all existing role names.
 List<String> getAllTables()
          Get all table names for the current database.
 List<String> getAllTables(String dbName)
          Get all table names for the specified database.
 HiveConf getConf()
           
 org.apache.hadoop.hive.metastore.api.Database getDatabase(String dbName)
          Get the database by name.
 org.apache.hadoop.hive.metastore.api.Database getDatabaseCurrent()
          Get the Database object for current database
 List<String> getDatabasesByPattern(String databasePattern)
          Get all existing databases that match the given pattern.
 String getDelegationToken(String owner, String renewer)
           
static List<org.apache.hadoop.hive.metastore.api.FieldSchema> getFieldsFromDeserializer(String name, Deserializer serde)
           
 org.apache.hadoop.hive.metastore.api.Function getFunction(String dbName, String funcName)
           
 List<String> getFunctions(String dbName, String pattern)
           
 org.apache.hadoop.hive.metastore.api.Index getIndex(String qualifiedIndexName)
           
 org.apache.hadoop.hive.metastore.api.Index getIndex(String baseTableName, String indexName)
           
 org.apache.hadoop.hive.metastore.api.Index getIndex(String dbName, String baseTableName, String indexName)
           
 List<org.apache.hadoop.hive.metastore.api.Index> getIndexes(String dbName, String tblName, short max)
           
 IMetaStoreClient getMSC()
           
 Partition getPartition(Table tbl, Map<String,String> partSpec, boolean forceCreate)
           
 Partition getPartition(Table tbl, Map<String,String> partSpec, boolean forceCreate, String partPath, boolean inheritTableSpecs)
          Returns partition metadata
 Map<String,List<org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj>> getPartitionColumnStatistics(String dbName, String tableName, List<String> partNames, List<String> colNames)
           
 List<String> getPartitionNames(String tblName, short max)
           
 List<String> getPartitionNames(String dbName, String tblName, Map<String,String> partSpec, short max)
           
 List<String> getPartitionNames(String dbName, String tblName, short max)
           
 List<Partition> getPartitions(Table tbl)
          get all the partitions that the table has
 List<Partition> getPartitions(Table tbl, Map<String,String> partialPartSpec)
          get all the partitions of the table that matches the given partial specification.
 List<Partition> getPartitions(Table tbl, Map<String,String> partialPartSpec, short limit)
          get all the partitions of the table that matches the given partial specification.
 boolean getPartitionsByExpr(Table tbl, ExprNodeGenericFuncDesc expr, HiveConf conf, List<Partition> result)
          Get a list of Partitions by expr.
 List<Partition> getPartitionsByFilter(Table tbl, String filter)
          Get a list of Partitions by filter.
 List<Partition> getPartitionsByNames(Table tbl, List<String> partNames)
          Get all partitions of the table that matches the list of given partition names.
 List<Partition> getPartitionsByNames(Table tbl, Map<String,String> partialPartSpec)
          get all the partitions of the table that matches the given partial specification.
static String[] getQualifiedNames(String qualifiedName)
           
 List<org.apache.hadoop.hive.metastore.api.RolePrincipalGrant> getRoleGrantInfoForPrincipal(String principalName, org.apache.hadoop.hive.metastore.api.PrincipalType principalType)
           
 Table getTable(String tableName)
          Returns metadata for the table named tableName
 Table getTable(String tableName, boolean throwException)
          Returns metadata for the table named tableName
 Table getTable(String dbName, String tableName)
          Returns metadata of the table
 Table getTable(String dbName, String tableName, boolean throwException)
          Returns metadata of the table
 List<org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj> getTableColumnStatistics(String dbName, String tableName, List<String> colNames)
           
 List<String> getTablesByPattern(String tablePattern)
          Returns all existing tables from default database which match the given pattern.
 List<String> getTablesByPattern(String dbName, String tablePattern)
          Returns all existing tables from the specified database which match the given pattern.
 List<String> getTablesForDb(String database, String tablePattern)
          Returns all existing tables from the given database which match the given pattern.
 boolean grantPrivileges(org.apache.hadoop.hive.metastore.api.PrivilegeBag privileges)
           
 boolean grantRole(String roleName, String userName, org.apache.hadoop.hive.metastore.api.PrincipalType principalType, String grantor, org.apache.hadoop.hive.metastore.api.PrincipalType grantorType, boolean grantOption)
           
 List<org.apache.hadoop.hive.metastore.api.Role> listRoles(String userName, org.apache.hadoop.hive.metastore.api.PrincipalType principalType)
           
 ArrayList<LinkedHashMap<String,String>> loadDynamicPartitions(org.apache.hadoop.fs.Path loadPath, String tableName, Map<String,String> partSpec, boolean replace, int numDP, boolean holdDDLTime, boolean listBucketingEnabled)
          Given a source directory name of the load path, load all dynamically generated partitions into the specified table and return a list of strings that represent the dynamic partition paths.
 void loadPartition(org.apache.hadoop.fs.Path loadPath, String tableName, Map<String,String> partSpec, boolean replace, boolean holdDDLTime, boolean inheritTableSpecs, boolean isSkewedStoreAsSubdir)
          Load a directory into a Hive Table Partition - Alters existing content of the partition with the contents of loadPath.
 void loadTable(org.apache.hadoop.fs.Path loadPath, String tableName, boolean replace, boolean holdDDLTime)
          Load a directory into a Hive Table.
 Table newTable(String tableName)
           
 void renamePartition(Table tbl, Map<String,String> oldPartSpec, Partition newPart)
          Rename a old partition to new partition
 boolean revokePrivileges(org.apache.hadoop.hive.metastore.api.PrivilegeBag privileges)
           
 boolean revokeRole(String roleName, String userName, org.apache.hadoop.hive.metastore.api.PrincipalType principalType)
           
static void set(Hive hive)
           
 org.apache.hadoop.hive.metastore.api.ShowCompactResponse showCompactions()
           
 List<org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege> showPrivilegeGrant(org.apache.hadoop.hive.metastore.api.HiveObjectType objectType, String principalName, org.apache.hadoop.hive.metastore.api.PrincipalType principalType, String dbName, String tableName, List<String> partValues, String columnName)
           
 org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse showTransactions()
           
 boolean updatePartitionColumnStatistics(org.apache.hadoop.hive.metastore.api.ColumnStatistics statsObj)
           
 boolean updateTableColumnStatistics(org.apache.hadoop.hive.metastore.api.ColumnStatistics statsObj)
           
 void validatePartitionNameCharacters(List<String> partVals)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static Hive get(HiveConf c)
                throws HiveException
Gets hive object for the current thread. If one is not initialized then a new one is created If the new configuration is different in metadata conf vars then a new one is created.

Parameters:
c - new Hive Configuration
Returns:
Hive object for current thread
Throws:
HiveException

get

public static Hive get(HiveConf c,
                       boolean needsRefresh)
                throws HiveException
get a connection to metastore. see get(HiveConf) function for comments

Parameters:
c - new conf
needsRefresh - if true then creates a new one
Returns:
The connection to the metastore
Throws:
HiveException

get

public static Hive get()
                throws HiveException
Throws:
HiveException

set

public static void set(Hive hive)

closeCurrent

public static void closeCurrent()

createDatabase

public void createDatabase(org.apache.hadoop.hive.metastore.api.Database db,
                           boolean ifNotExist)
                    throws org.apache.hadoop.hive.metastore.api.AlreadyExistsException,
                           HiveException
Create a database

Parameters:
db -
ifNotExist - if true, will ignore AlreadyExistsException exception
Throws:
org.apache.hadoop.hive.metastore.api.AlreadyExistsException
HiveException

createDatabase

public void createDatabase(org.apache.hadoop.hive.metastore.api.Database db)
                    throws org.apache.hadoop.hive.metastore.api.AlreadyExistsException,
                           HiveException
Create a Database. Raise an error if a database with the same name already exists.

Parameters:
db -
Throws:
org.apache.hadoop.hive.metastore.api.AlreadyExistsException
HiveException

dropDatabase

public void dropDatabase(String name)
                  throws HiveException,
                         org.apache.hadoop.hive.metastore.api.NoSuchObjectException
Drop a database.

Parameters:
name -
Throws:
org.apache.hadoop.hive.metastore.api.NoSuchObjectException
HiveException
See Also:
HiveMetaStoreClient.dropDatabase(java.lang.String)

dropDatabase

public void dropDatabase(String name,
                         boolean deleteData,
                         boolean ignoreUnknownDb)
                  throws HiveException,
                         org.apache.hadoop.hive.metastore.api.NoSuchObjectException
Drop a database

Parameters:
name -
deleteData -
ignoreUnknownDb - if true, will ignore NoSuchObjectException
Throws:
HiveException
org.apache.hadoop.hive.metastore.api.NoSuchObjectException

dropDatabase

public void dropDatabase(String name,
                         boolean deleteData,
                         boolean ignoreUnknownDb,
                         boolean cascade)
                  throws HiveException,
                         org.apache.hadoop.hive.metastore.api.NoSuchObjectException
Drop a database

Parameters:
name -
deleteData -
ignoreUnknownDb - if true, will ignore NoSuchObjectException
cascade - if true, delete all tables on the DB if exists. Othewise, the query will fail if table still exists.
Throws:
HiveException
org.apache.hadoop.hive.metastore.api.NoSuchObjectException

createTable

public void createTable(String tableName,
                        List<String> columns,
                        List<String> partCols,
                        Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat,
                        Class<?> fileOutputFormat)
                 throws HiveException
Creates a table metdata and the directory for the table data

Parameters:
tableName - name of the table
columns - list of fields of the table
partCols - partition keys of the table
fileInputFormat - Class of the input format of the table data file
fileOutputFormat - Class of the output format of the table data file
Throws:
HiveException - thrown if the args are invalid or if the metadata or the data directory couldn't be created

createTable

public void createTable(String tableName,
                        List<String> columns,
                        List<String> partCols,
                        Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat,
                        Class<?> fileOutputFormat,
                        int bucketCount,
                        List<String> bucketCols)
                 throws HiveException
Creates a table metdata and the directory for the table data

Parameters:
tableName - name of the table
columns - list of fields of the table
partCols - partition keys of the table
fileInputFormat - Class of the input format of the table data file
fileOutputFormat - Class of the output format of the table data file
bucketCount - number of buckets that each partition (or the table itself) should be divided into
Throws:
HiveException - thrown if the args are invalid or if the metadata or the data directory couldn't be created

alterTable

public void alterTable(String tblName,
                       Table newTbl)
                throws org.apache.hadoop.hive.metastore.api.InvalidOperationException,
                       HiveException
Updates the existing table metadata with the new metadata.

Parameters:
tblName - name of the existing table
newTbl - new name of the table. could be the old name
Throws:
org.apache.hadoop.hive.metastore.api.InvalidOperationException - if the changes in metadata is not acceptable
org.apache.thrift.TException
HiveException

alterIndex

public void alterIndex(String dbName,
                       String baseTblName,
                       String idxName,
                       org.apache.hadoop.hive.metastore.api.Index newIdx)
                throws org.apache.hadoop.hive.metastore.api.InvalidOperationException,
                       HiveException
Updates the existing index metadata with the new metadata.

Parameters:
idxName - name of the existing index
newIdx - new name of the index. could be the old name
Throws:
org.apache.hadoop.hive.metastore.api.InvalidOperationException - if the changes in metadata is not acceptable
org.apache.thrift.TException
HiveException

alterPartition

public void alterPartition(String tblName,
                           Partition newPart)
                    throws org.apache.hadoop.hive.metastore.api.InvalidOperationException,
                           HiveException
Updates the existing partition metadata with the new metadata.

Parameters:
tblName - name of the existing table
newPart - new partition
Throws:
org.apache.hadoop.hive.metastore.api.InvalidOperationException - if the changes in metadata is not acceptable
org.apache.thrift.TException
HiveException

alterPartition

public void alterPartition(String dbName,
                           String tblName,
                           Partition newPart)
                    throws org.apache.hadoop.hive.metastore.api.InvalidOperationException,
                           HiveException
Updates the existing partition metadata with the new metadata.

Parameters:
dbName - name of the exiting table's database
tblName - name of the existing table
newPart - new partition
Throws:
org.apache.hadoop.hive.metastore.api.InvalidOperationException - if the changes in metadata is not acceptable
org.apache.thrift.TException
HiveException

alterPartitions

public void alterPartitions(String tblName,
                            List<Partition> newParts)
                     throws org.apache.hadoop.hive.metastore.api.InvalidOperationException,
                            HiveException
Updates the existing table metadata with the new metadata.

Parameters:
tblName - name of the existing table
newParts - new partitions
Throws:
org.apache.hadoop.hive.metastore.api.InvalidOperationException - if the changes in metadata is not acceptable
org.apache.thrift.TException
HiveException

renamePartition

public void renamePartition(Table tbl,
                            Map<String,String> oldPartSpec,
                            Partition newPart)
                     throws HiveException
Rename a old partition to new partition

Parameters:
tbl - existing table
oldPartSpec - spec of old partition
newPart - new partition
Throws:
org.apache.hadoop.hive.metastore.api.InvalidOperationException - if the changes in metadata is not acceptable
org.apache.thrift.TException
HiveException

alterDatabase

public void alterDatabase(String dbName,
                          org.apache.hadoop.hive.metastore.api.Database db)
                   throws HiveException
Throws:
HiveException

createTable

public void createTable(Table tbl)
                 throws HiveException
Creates the table with the give objects

Parameters:
tbl - a table object
Throws:
HiveException

createTable

public void createTable(Table tbl,
                        boolean ifNotExists)
                 throws HiveException
Creates the table with the give objects

Parameters:
tbl - a table object
ifNotExists - if true, ignore AlreadyExistsException
Throws:
HiveException

createIndex

public void createIndex(String tableName,
                        String indexName,
                        String indexHandlerClass,
                        List<String> indexedCols,
                        String indexTblName,
                        boolean deferredRebuild,
                        String inputFormat,
                        String outputFormat,
                        String serde,
                        String storageHandler,
                        String location,
                        Map<String,String> idxProps,
                        Map<String,String> tblProps,
                        Map<String,String> serdeProps,
                        String collItemDelim,
                        String fieldDelim,
                        String fieldEscape,
                        String lineDelim,
                        String mapKeyDelim,
                        String indexComment)
                 throws HiveException
Parameters:
tableName - table name
indexName - index name
indexHandlerClass - index handler class
indexedCols - index columns
indexTblName - index table's name
deferredRebuild - referred build index table's data
inputFormat - input format
outputFormat - output format
serde -
storageHandler - index table's storage handler
location - location
idxProps - idx
serdeProps - serde properties
collItemDelim -
fieldDelim -
fieldEscape -
lineDelim -
mapKeyDelim -
Throws:
HiveException

getIndex

public org.apache.hadoop.hive.metastore.api.Index getIndex(String qualifiedIndexName)
                                                    throws HiveException
Throws:
HiveException

getIndex

public org.apache.hadoop.hive.metastore.api.Index getIndex(String baseTableName,
                                                           String indexName)
                                                    throws HiveException
Throws:
HiveException

getIndex

public org.apache.hadoop.hive.metastore.api.Index getIndex(String dbName,
                                                           String baseTableName,
                                                           String indexName)
                                                    throws HiveException
Throws:
HiveException

dropIndex

public boolean dropIndex(String db_name,
                         String tbl_name,
                         String index_name,
                         boolean deleteData)
                  throws HiveException
Throws:
HiveException

dropTable

public void dropTable(String tableName)
               throws HiveException
Drops table along with the data in it. If the table doesn't exist then it is a no-op

Parameters:
tableName - table to drop
Throws:
HiveException - thrown if the drop fails

dropTable

public void dropTable(String dbName,
                      String tableName)
               throws HiveException
Drops table along with the data in it. If the table doesn't exist then it is a no-op

Parameters:
dbName - database where the table lives
tableName - table to drop
Throws:
HiveException - thrown if the drop fails

dropTable

public void dropTable(String dbName,
                      String tableName,
                      boolean deleteData,
                      boolean ignoreUnknownTab)
               throws HiveException
Drops the table.

Parameters:
dbName -
tableName -
deleteData - deletes the underlying data along with metadata
ignoreUnknownTab - an exception if thrown if this is falser and table doesn't exist
Throws:
HiveException

getConf

public HiveConf getConf()

getTable

public Table getTable(String tableName)
               throws HiveException
Returns metadata for the table named tableName

Parameters:
tableName - the name of the table
Returns:
the table metadata
Throws:
HiveException - if there's an internal error or if the table doesn't exist

getTable

public Table getTable(String tableName,
                      boolean throwException)
               throws HiveException
Returns metadata for the table named tableName

Parameters:
tableName - the name of the table
throwException - controls whether an exception is thrown or a returns a null
Returns:
the table metadata
Throws:
HiveException - if there's an internal error or if the table doesn't exist

getTable

public Table getTable(String dbName,
                      String tableName)
               throws HiveException
Returns metadata of the table

Parameters:
dbName - the name of the database
tableName - the name of the table
Returns:
the table
Throws:
HiveException - if there's an internal error or if the table doesn't exist

getTable

public Table getTable(String dbName,
                      String tableName,
                      boolean throwException)
               throws HiveException
Returns metadata of the table

Parameters:
dbName - the name of the database
tableName - the name of the table
throwException - controls whether an exception is thrown or a returns a null
Returns:
the table or if throwException is false a null value.
Throws:
HiveException

getAllTables

public List<String> getAllTables()
                          throws HiveException
Get all table names for the current database.

Returns:
List of table names
Throws:
HiveException

getAllTables

public List<String> getAllTables(String dbName)
                          throws HiveException
Get all table names for the specified database.

Parameters:
dbName -
Returns:
List of table names
Throws:
HiveException

getTablesByPattern

public List<String> getTablesByPattern(String tablePattern)
                                throws HiveException
Returns all existing tables from default database which match the given pattern. The matching occurs as per Java regular expressions

Parameters:
tablePattern - java re pattern
Returns:
list of table names
Throws:
HiveException

getTablesByPattern

public List<String> getTablesByPattern(String dbName,
                                       String tablePattern)
                                throws HiveException
Returns all existing tables from the specified database which match the given pattern. The matching occurs as per Java regular expressions.

Parameters:
dbName -
tablePattern -
Returns:
list of table names
Throws:
HiveException

getTablesForDb

public List<String> getTablesForDb(String database,
                                   String tablePattern)
                            throws HiveException
Returns all existing tables from the given database which match the given pattern. The matching occurs as per Java regular expressions

Parameters:
database - the database name
tablePattern - java re pattern
Returns:
list of table names
Throws:
HiveException

getAllDatabases

public List<String> getAllDatabases()
                             throws HiveException
Get all existing database names.

Returns:
List of database names.
Throws:
HiveException

getDatabasesByPattern

public List<String> getDatabasesByPattern(String databasePattern)
                                   throws HiveException
Get all existing databases that match the given pattern. The matching occurs as per Java regular expressions

Parameters:
databasePattern - java re pattern
Returns:
list of database names
Throws:
HiveException

grantPrivileges

public boolean grantPrivileges(org.apache.hadoop.hive.metastore.api.PrivilegeBag privileges)
                        throws HiveException
Throws:
HiveException

revokePrivileges

public boolean revokePrivileges(org.apache.hadoop.hive.metastore.api.PrivilegeBag privileges)
                         throws HiveException
Parameters:
privileges - a bag of privileges
Returns:
true on success
Throws:
HiveException

databaseExists

public boolean databaseExists(String dbName)
                       throws HiveException
Query metadata to see if a database with the given name already exists.

Parameters:
dbName -
Returns:
true if a database with the given name already exists, false if does not exist.
Throws:
HiveException

getDatabase

public org.apache.hadoop.hive.metastore.api.Database getDatabase(String dbName)
                                                          throws HiveException
Get the database by name.

Parameters:
dbName - the name of the database.
Returns:
a Database object if this database exists, null otherwise.
Throws:
HiveException

getDatabaseCurrent

public org.apache.hadoop.hive.metastore.api.Database getDatabaseCurrent()
                                                                 throws HiveException
Get the Database object for current database

Returns:
a Database object if this database exists, null otherwise.
Throws:
HiveException

loadPartition

public void loadPartition(org.apache.hadoop.fs.Path loadPath,
                          String tableName,
                          Map<String,String> partSpec,
                          boolean replace,
                          boolean holdDDLTime,
                          boolean inheritTableSpecs,
                          boolean isSkewedStoreAsSubdir)
                   throws HiveException
Load a directory into a Hive Table Partition - Alters existing content of the partition with the contents of loadPath. - If the partition does not exist - one is created - files in loadPath are moved into Hive. But the directory itself is not removed.

Parameters:
loadPath - Directory containing files to load into Table
tableName - name of table to be loaded.
partSpec - defines which partition needs to be loaded
replace - if true - replace files in the partition, otherwise add files to the partition
holdDDLTime - if true, force [re]create the partition
inheritTableSpecs - if true, on [re]creating the partition, take the location/inputformat/outputformat/serde details from table spec
Throws:
HiveException

loadDynamicPartitions

public ArrayList<LinkedHashMap<String,String>> loadDynamicPartitions(org.apache.hadoop.fs.Path loadPath,
                                                                     String tableName,
                                                                     Map<String,String> partSpec,
                                                                     boolean replace,
                                                                     int numDP,
                                                                     boolean holdDDLTime,
                                                                     boolean listBucketingEnabled)
                                                              throws HiveException
Given a source directory name of the load path, load all dynamically generated partitions into the specified table and return a list of strings that represent the dynamic partition paths.

Parameters:
loadPath -
tableName -
partSpec -
replace -
numDP - number of dynamic partitions
holdDDLTime -
Returns:
a list of strings with the dynamic partition paths
Throws:
HiveException

loadTable

public void loadTable(org.apache.hadoop.fs.Path loadPath,
                      String tableName,
                      boolean replace,
                      boolean holdDDLTime)
               throws HiveException
Load a directory into a Hive Table. - Alters existing content of table with the contents of loadPath. - If table does not exist - an exception is thrown - files in loadPath are moved into Hive. But the directory itself is not removed.

Parameters:
loadPath - Directory containing files to load into Table
tableName - name of table to be loaded.
replace - if true - replace files in the table, otherwise add files to table
holdDDLTime -
Throws:
HiveException

createPartition

public Partition createPartition(Table tbl,
                                 Map<String,String> partSpec)
                          throws HiveException
Creates a partition.

Parameters:
tbl - table for which partition needs to be created
partSpec - partition keys and their values
Returns:
created partition object
Throws:
HiveException - if table doesn't exist or partition already exists

createPartitions

public List<Partition> createPartitions(AddPartitionDesc addPartitionDesc)
                                 throws HiveException
Throws:
HiveException

getPartition

public Partition getPartition(Table tbl,
                              Map<String,String> partSpec,
                              boolean forceCreate)
                       throws HiveException
Throws:
HiveException

getPartition

public Partition getPartition(Table tbl,
                              Map<String,String> partSpec,
                              boolean forceCreate,
                              String partPath,
                              boolean inheritTableSpecs)
                       throws HiveException
Returns partition metadata

Parameters:
tbl - the partition's table
partSpec - partition keys and values
forceCreate - if this is true and partition doesn't exist then a partition is created
partPath - the path where the partition data is located
inheritTableSpecs - whether to copy over the table specs for if/of/serde
Returns:
result partition object or null if there is no partition
Throws:
HiveException

dropPartition

public boolean dropPartition(String tblName,
                             List<String> part_vals,
                             boolean deleteData)
                      throws HiveException
Throws:
HiveException

dropPartition

public boolean dropPartition(String db_name,
                             String tbl_name,
                             List<String> part_vals,
                             boolean deleteData)
                      throws HiveException
Throws:
HiveException

dropPartitions

public List<Partition> dropPartitions(String tblName,
                                      List<DropTableDesc.PartSpec> partSpecs,
                                      boolean deleteData,
                                      boolean ignoreProtection,
                                      boolean ifExists)
                               throws HiveException
Throws:
HiveException

dropPartitions

public List<Partition> dropPartitions(String dbName,
                                      String tblName,
                                      List<DropTableDesc.PartSpec> partSpecs,
                                      boolean deleteData,
                                      boolean ignoreProtection,
                                      boolean ifExists)
                               throws HiveException
Throws:
HiveException

getPartitionNames

public List<String> getPartitionNames(String tblName,
                                      short max)
                               throws HiveException
Throws:
HiveException

getPartitionNames

public List<String> getPartitionNames(String dbName,
                                      String tblName,
                                      short max)
                               throws HiveException
Throws:
HiveException

getPartitionNames

public List<String> getPartitionNames(String dbName,
                                      String tblName,
                                      Map<String,String> partSpec,
                                      short max)
                               throws HiveException
Throws:
HiveException

getPartitions

public List<Partition> getPartitions(Table tbl)
                              throws HiveException
get all the partitions that the table has

Parameters:
tbl - object for which partition is needed
Returns:
list of partition objects
Throws:
HiveException

getAllPartitionsOf

public Set<Partition> getAllPartitionsOf(Table tbl)
                                  throws HiveException
Get all the partitions; unlike getPartitions(Table), does not include auth.

Parameters:
tbl - table for which partitions are needed
Returns:
list of partition objects
Throws:
HiveException

getPartitions

public List<Partition> getPartitions(Table tbl,
                                     Map<String,String> partialPartSpec,
                                     short limit)
                              throws HiveException
get all the partitions of the table that matches the given partial specification. partition columns whose value is can be anything should be an empty string.

Parameters:
tbl - object for which partition is needed. Must be partitioned.
limit - number of partitions to return
Returns:
list of partition objects
Throws:
HiveException

getPartitions

public List<Partition> getPartitions(Table tbl,
                                     Map<String,String> partialPartSpec)
                              throws HiveException
get all the partitions of the table that matches the given partial specification. partition columns whose value is can be anything should be an empty string.

Parameters:
tbl - object for which partition is needed. Must be partitioned.
Returns:
list of partition objects
Throws:
HiveException

getPartitionsByNames

public List<Partition> getPartitionsByNames(Table tbl,
                                            Map<String,String> partialPartSpec)
                                     throws HiveException
get all the partitions of the table that matches the given partial specification. partition columns whose value is can be anything should be an empty string.

Parameters:
tbl - object for which partition is needed. Must be partitioned.
partialPartSpec - partial partition specification (some subpartitions can be empty).
Returns:
list of partition objects
Throws:
HiveException

getPartitionsByNames

public List<Partition> getPartitionsByNames(Table tbl,
                                            List<String> partNames)
                                     throws HiveException
Get all partitions of the table that matches the list of given partition names.

Parameters:
tbl - object for which partition is needed. Must be partitioned.
partNames - list of partition names
Returns:
list of partition objects
Throws:
HiveException

getPartitionsByFilter

public List<Partition> getPartitionsByFilter(Table tbl,
                                             String filter)
                                      throws HiveException,
                                             org.apache.hadoop.hive.metastore.api.MetaException,
                                             org.apache.hadoop.hive.metastore.api.NoSuchObjectException,
                                             org.apache.thrift.TException
Get a list of Partitions by filter.

Parameters:
tbl - The table containing the partitions.
filter - A string represent partition predicates.
Returns:
a list of partitions satisfying the partition predicates.
Throws:
HiveException
org.apache.hadoop.hive.metastore.api.MetaException
org.apache.hadoop.hive.metastore.api.NoSuchObjectException
org.apache.thrift.TException

getPartitionsByExpr

public boolean getPartitionsByExpr(Table tbl,
                                   ExprNodeGenericFuncDesc expr,
                                   HiveConf conf,
                                   List<Partition> result)
                            throws HiveException,
                                   org.apache.thrift.TException
Get a list of Partitions by expr.

Parameters:
tbl - The table containing the partitions.
expr - A serialized expression for partition predicates.
conf - Hive config.
result - the resulting list of partitions
Returns:
whether the resulting list contains partitions which may or may not match the expr
Throws:
HiveException
org.apache.thrift.TException

validatePartitionNameCharacters

public void validatePartitionNameCharacters(List<String> partVals)
                                     throws HiveException
Throws:
HiveException

createRole

public void createRole(String roleName,
                       String ownerName)
                throws HiveException
Throws:
HiveException

dropRole

public void dropRole(String roleName)
              throws HiveException
Throws:
HiveException

getAllRoleNames

public List<String> getAllRoleNames()
                             throws HiveException
Get all existing role names.

Returns:
List of role names.
Throws:
HiveException

getRoleGrantInfoForPrincipal

public List<org.apache.hadoop.hive.metastore.api.RolePrincipalGrant> getRoleGrantInfoForPrincipal(String principalName,
                                                                                                  org.apache.hadoop.hive.metastore.api.PrincipalType principalType)
                                                                                           throws HiveException
Throws:
HiveException

grantRole

public boolean grantRole(String roleName,
                         String userName,
                         org.apache.hadoop.hive.metastore.api.PrincipalType principalType,
                         String grantor,
                         org.apache.hadoop.hive.metastore.api.PrincipalType grantorType,
                         boolean grantOption)
                  throws HiveException
Throws:
HiveException

revokeRole

public boolean revokeRole(String roleName,
                          String userName,
                          org.apache.hadoop.hive.metastore.api.PrincipalType principalType)
                   throws HiveException
Throws:
HiveException

listRoles

public List<org.apache.hadoop.hive.metastore.api.Role> listRoles(String userName,
                                                                 org.apache.hadoop.hive.metastore.api.PrincipalType principalType)
                                                          throws HiveException
Throws:
HiveException

get_privilege_set

public org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet get_privilege_set(org.apache.hadoop.hive.metastore.api.HiveObjectType objectType,
                                                                                    String db_name,
                                                                                    String table_name,
                                                                                    List<String> part_values,
                                                                                    String column_name,
                                                                                    String user_name,
                                                                                    List<String> group_names)
                                                                             throws HiveException
Parameters:
objectType - hive object type
db_name - database name
table_name - table name
part_values - partition values
column_name - column name
user_name - user name
group_names - group names
Returns:
the privilege set
Throws:
HiveException

showPrivilegeGrant

public List<org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege> showPrivilegeGrant(org.apache.hadoop.hive.metastore.api.HiveObjectType objectType,
                                                                                         String principalName,
                                                                                         org.apache.hadoop.hive.metastore.api.PrincipalType principalType,
                                                                                         String dbName,
                                                                                         String tableName,
                                                                                         List<String> partValues,
                                                                                         String columnName)
                                                                                  throws HiveException
Parameters:
objectType - hive object type
principalName -
principalType -
dbName -
tableName -
partValues -
columnName -
Returns:
list of privileges
Throws:
HiveException

exchangeTablePartitions

public void exchangeTablePartitions(Map<String,String> partitionSpecs,
                                    String sourceDb,
                                    String sourceTable,
                                    String destDb,
                                    String destinationTableName)
                             throws HiveException
Throws:
HiveException

getMSC

@InterfaceAudience.LimitedPrivate(value="Hive")
@InterfaceStability.Unstable
public IMetaStoreClient getMSC()
                        throws org.apache.hadoop.hive.metastore.api.MetaException
Returns:
the metastore client for the current thread
Throws:
org.apache.hadoop.hive.metastore.api.MetaException

getFieldsFromDeserializer

public static List<org.apache.hadoop.hive.metastore.api.FieldSchema> getFieldsFromDeserializer(String name,
                                                                                               Deserializer serde)
                                                                                        throws HiveException
Throws:
HiveException

getIndexes

public List<org.apache.hadoop.hive.metastore.api.Index> getIndexes(String dbName,
                                                                   String tblName,
                                                                   short max)
                                                            throws HiveException
Throws:
HiveException

updateTableColumnStatistics

public boolean updateTableColumnStatistics(org.apache.hadoop.hive.metastore.api.ColumnStatistics statsObj)
                                    throws HiveException
Throws:
HiveException

updatePartitionColumnStatistics

public boolean updatePartitionColumnStatistics(org.apache.hadoop.hive.metastore.api.ColumnStatistics statsObj)
                                        throws HiveException
Throws:
HiveException

getTableColumnStatistics

public List<org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj> getTableColumnStatistics(String dbName,
                                                                                               String tableName,
                                                                                               List<String> colNames)
                                                                                        throws HiveException
Throws:
HiveException

getPartitionColumnStatistics

public Map<String,List<org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj>> getPartitionColumnStatistics(String dbName,
                                                                                                               String tableName,
                                                                                                               List<String> partNames,
                                                                                                               List<String> colNames)
                                                                                                        throws HiveException
Throws:
HiveException

deleteTableColumnStatistics

public boolean deleteTableColumnStatistics(String dbName,
                                           String tableName,
                                           String colName)
                                    throws HiveException
Throws:
HiveException

deletePartitionColumnStatistics

public boolean deletePartitionColumnStatistics(String dbName,
                                               String tableName,
                                               String partName,
                                               String colName)
                                        throws HiveException
Throws:
HiveException

newTable

public Table newTable(String tableName)
               throws HiveException
Throws:
HiveException

getDelegationToken

public String getDelegationToken(String owner,
                                 String renewer)
                          throws HiveException
Throws:
HiveException

cancelDelegationToken

public void cancelDelegationToken(String tokenStrForm)
                           throws HiveException
Throws:
HiveException

compact

public void compact(String dbname,
                    String tableName,
                    String partName,
                    String compactType)
             throws HiveException
Enqueue a compaction request.

Parameters:
dbname - name of the database, if null default will be used.
tableName - name of the table, cannot be null
partName - name of the partition, if null table will be compacted (valid only for non-partitioned tables).
compactType - major or minor
Throws:
HiveException

showCompactions

public org.apache.hadoop.hive.metastore.api.ShowCompactResponse showCompactions()
                                                                         throws HiveException
Throws:
HiveException

showTransactions

public org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse showTransactions()
                                                                              throws HiveException
Throws:
HiveException

getQualifiedNames

public static String[] getQualifiedNames(String qualifiedName)

createFunction

public void createFunction(org.apache.hadoop.hive.metastore.api.Function func)
                    throws HiveException
Throws:
HiveException

alterFunction

public void alterFunction(String dbName,
                          String funcName,
                          org.apache.hadoop.hive.metastore.api.Function newFunction)
                   throws HiveException
Throws:
HiveException

dropFunction

public void dropFunction(String dbName,
                         String funcName)
                  throws HiveException
Throws:
HiveException

getFunction

public org.apache.hadoop.hive.metastore.api.Function getFunction(String dbName,
                                                                 String funcName)
                                                          throws HiveException
Throws:
HiveException

getFunctions

public List<String> getFunctions(String dbName,
                                 String pattern)
                          throws HiveException
Throws:
HiveException


Copyright © 2014 The Apache Software Foundation. All rights reserved.