public interface HiveClient
Modifier and Type | Method and Description |
---|---|
void |
addJar(String path)
Add a jar into class loader
|
void |
alterDatabase(org.apache.spark.sql.catalyst.catalog.CatalogDatabase database)
Alter a database whose name matches the one specified in
database , assuming it exists. |
void |
alterFunction(String db,
org.apache.spark.sql.catalyst.catalog.CatalogFunction func)
Alter a function whose name matches the one specified in `func`, assuming it exists.
|
void |
alterPartitions(String db,
String table,
scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> newParts)
Alter one or more table partitions whose specs match the ones specified in
newParts ,
assuming the partitions exist. |
void |
alterTable(org.apache.spark.sql.catalyst.catalog.CatalogTable table)
Alter a table whose name matches the one specified in `table`, assuming it exists.
|
void |
alterTable(String dbName,
String tableName,
org.apache.spark.sql.catalyst.catalog.CatalogTable table)
Updates the given table with new metadata, optionally renaming the table or
moving across different database.
|
void |
alterTableDataSchema(String dbName,
String tableName,
StructType newDataSchema,
scala.collection.immutable.Map<String,String> schemaProps)
Updates the given table with a new data schema and table properties, and keep everything else
unchanged.
|
void |
createDatabase(org.apache.spark.sql.catalyst.catalog.CatalogDatabase database,
boolean ignoreIfExists)
Creates a new database with the given name.
|
void |
createFunction(String db,
org.apache.spark.sql.catalyst.catalog.CatalogFunction func)
Create a function in an existing database.
|
void |
createPartitions(String db,
String table,
scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> parts,
boolean ignoreIfExists)
Create one or many partitions in the given table.
|
void |
createTable(org.apache.spark.sql.catalyst.catalog.CatalogTable table,
boolean ignoreIfExists)
Creates a table with the given metadata.
|
boolean |
databaseExists(String dbName)
Return whether a table/view with the specified name exists.
|
void |
dropDatabase(String name,
boolean ignoreIfNotExists,
boolean cascade)
Drop the specified database, if it exists.
|
void |
dropFunction(String db,
String name)
Drop an existing function in the database.
|
void |
dropPartitions(String db,
String table,
scala.collection.Seq<scala.collection.immutable.Map<String,String>> specs,
boolean ignoreIfNotExists,
boolean purge,
boolean retainData)
Drop one or many partitions in the given table, assuming they exist.
|
void |
dropTable(String dbName,
String tableName,
boolean ignoreIfNotExists,
boolean purge)
Drop the specified table.
|
boolean |
functionExists(String db,
String name)
Return whether a function exists in the specified database.
|
String |
getConf(String key,
String defaultValue)
Returns the configuration for the given key in the current session.
|
org.apache.spark.sql.catalyst.catalog.CatalogDatabase |
getDatabase(String name)
Returns the metadata for specified database, throwing an exception if it doesn't exist
|
org.apache.spark.sql.catalyst.catalog.CatalogFunction |
getFunction(String db,
String name)
Return an existing function in the database, assuming it exists.
|
scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogFunction> |
getFunctionOption(String db,
String name)
Return an existing function in the database, or None if it doesn't exist.
|
org.apache.spark.sql.catalyst.catalog.CatalogTablePartition |
getPartition(String dbName,
String tableName,
scala.collection.immutable.Map<String,String> spec)
Returns the specified partition, or throws `NoSuchPartitionException`.
|
scala.collection.Seq<String> |
getPartitionNames(org.apache.spark.sql.catalyst.catalog.CatalogTable table,
scala.Option<scala.collection.immutable.Map<String,String>> partialSpec)
Returns the partition names for the given table that match the supplied partition spec.
|
scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> |
getPartitionOption(org.apache.spark.sql.catalyst.catalog.CatalogTable table,
scala.collection.immutable.Map<String,String> spec)
Returns the specified partition or None if it does not exist.
|
scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> |
getPartitionOption(String db,
String table,
scala.collection.immutable.Map<String,String> spec)
Returns the specified partition or None if it does not exist.
|
scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> |
getPartitions(org.apache.spark.sql.catalyst.catalog.CatalogTable catalogTable,
scala.Option<scala.collection.immutable.Map<String,String>> partialSpec)
Returns the partitions for the given table that match the supplied partition spec.
|
scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> |
getPartitions(String db,
String table,
scala.Option<scala.collection.immutable.Map<String,String>> partialSpec)
Returns the partitions for the given table that match the supplied partition spec.
|
scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> |
getPartitionsByFilter(org.apache.spark.sql.catalyst.catalog.CatalogTable catalogTable,
scala.collection.Seq<org.apache.spark.sql.catalyst.expressions.Expression> predicates)
Returns partitions filtered by predicates for the given table.
|
Object |
getState()
Return the associated Hive SessionState of this
HiveClientImpl |
org.apache.spark.sql.catalyst.catalog.CatalogTable |
getTable(String dbName,
String tableName)
Returns the specified table, or throws `NoSuchTableException`.
|
scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogTable> |
getTableOption(String dbName,
String tableName)
Returns the metadata for the specified table or None if it doesn't exist.
|
scala.collection.Seq<String> |
listDatabases(String pattern)
List the names of all the databases that match the specified pattern.
|
scala.collection.Seq<String> |
listFunctions(String db,
String pattern)
Return the names of all functions that match the given pattern in the database.
|
scala.collection.Seq<String> |
listTables(String dbName)
Returns the names of all tables in the given database.
|
scala.collection.Seq<String> |
listTables(String dbName,
String pattern)
Returns the names of tables in the given database that matches the given pattern.
|
void |
loadDynamicPartitions(String loadPath,
String dbName,
String tableName,
java.util.LinkedHashMap<String,String> partSpec,
boolean replace,
int numDP)
Loads new dynamic partitions into an existing table.
|
void |
loadPartition(String loadPath,
String dbName,
String tableName,
java.util.LinkedHashMap<String,String> partSpec,
boolean replace,
boolean inheritTableSpecs,
boolean isSrcLocal)
Loads a static partition into an existing table.
|
void |
loadTable(String loadPath,
String tableName,
boolean replace,
boolean isSrcLocal)
Loads data into an existing table.
|
HiveClient |
newSession()
Return a
HiveClient as new session, that will share the class loader and Hive client |
void |
renameFunction(String db,
String oldName,
String newName)
Rename an existing function in the database.
|
void |
renamePartitions(String db,
String table,
scala.collection.Seq<scala.collection.immutable.Map<String,String>> specs,
scala.collection.Seq<scala.collection.immutable.Map<String,String>> newSpecs)
Rename one or many existing table partitions, assuming they exist.
|
void |
reset()
Used for testing only.
|
scala.collection.Seq<String> |
runSqlHive(String sql)
Runs a HiveQL command using Hive, returning the results as a list of strings.
|
void |
setCurrentDatabase(String databaseName)
Sets the name of current database.
|
void |
setError(java.io.PrintStream stream) |
void |
setInfo(java.io.PrintStream stream) |
void |
setOut(java.io.PrintStream stream) |
boolean |
tableExists(String dbName,
String tableName)
Return whether a table/view with the specified name exists.
|
org.apache.spark.sql.hive.client.HiveVersion |
version()
Returns the Hive Version of this client.
|
<A> A |
withHiveState(scala.Function0<A> f)
Run a function within Hive state (SessionState, HiveConf, Hive client and class loader)
|
void addJar(String path)
void alterDatabase(org.apache.spark.sql.catalyst.catalog.CatalogDatabase database)
database
, assuming it exists.database
- (undocumented)void alterFunction(String db, org.apache.spark.sql.catalyst.catalog.CatalogFunction func)
void alterPartitions(String db, String table, scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> newParts)
newParts
,
assuming the partitions exist.db
- (undocumented)table
- (undocumented)newParts
- (undocumented)void alterTable(org.apache.spark.sql.catalyst.catalog.CatalogTable table)
void alterTable(String dbName, String tableName, org.apache.spark.sql.catalyst.catalog.CatalogTable table)
dbName
- (undocumented)tableName
- (undocumented)table
- (undocumented)void alterTableDataSchema(String dbName, String tableName, StructType newDataSchema, scala.collection.immutable.Map<String,String> schemaProps)
TODO(cloud-fan): it's a little hacky to introduce the schema table properties here in
HiveClient
, but we don't have a cleaner solution now.
dbName
- (undocumented)tableName
- (undocumented)newDataSchema
- (undocumented)schemaProps
- (undocumented)void createDatabase(org.apache.spark.sql.catalyst.catalog.CatalogDatabase database, boolean ignoreIfExists)
void createFunction(String db, org.apache.spark.sql.catalyst.catalog.CatalogFunction func)
void createPartitions(String db, String table, scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> parts, boolean ignoreIfExists)
db
- (undocumented)table
- (undocumented)parts
- (undocumented)ignoreIfExists
- (undocumented)void createTable(org.apache.spark.sql.catalyst.catalog.CatalogTable table, boolean ignoreIfExists)
boolean databaseExists(String dbName)
void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade)
name
- database to dropignoreIfNotExists
- if true, do not throw error if the database does not existcascade
- whether to remove all associated objects such as tables and functionsvoid dropFunction(String db, String name)
void dropPartitions(String db, String table, scala.collection.Seq<scala.collection.immutable.Map<String,String>> specs, boolean ignoreIfNotExists, boolean purge, boolean retainData)
db
- (undocumented)table
- (undocumented)specs
- (undocumented)ignoreIfNotExists
- (undocumented)purge
- (undocumented)retainData
- (undocumented)void dropTable(String dbName, String tableName, boolean ignoreIfNotExists, boolean purge)
boolean functionExists(String db, String name)
String getConf(String key, String defaultValue)
org.apache.spark.sql.catalyst.catalog.CatalogDatabase getDatabase(String name)
org.apache.spark.sql.catalyst.catalog.CatalogFunction getFunction(String db, String name)
scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogFunction> getFunctionOption(String db, String name)
org.apache.spark.sql.catalyst.catalog.CatalogTablePartition getPartition(String dbName, String tableName, scala.collection.immutable.Map<String,String> spec)
scala.collection.Seq<String> getPartitionNames(org.apache.spark.sql.catalyst.catalog.CatalogTable table, scala.Option<scala.collection.immutable.Map<String,String>> partialSpec)
The returned sequence is sorted as strings.
table
- (undocumented)partialSpec
- (undocumented)scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> getPartitionOption(String db, String table, scala.collection.immutable.Map<String,String> spec)
scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> getPartitionOption(org.apache.spark.sql.catalyst.catalog.CatalogTable table, scala.collection.immutable.Map<String,String> spec)
scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> getPartitions(String db, String table, scala.Option<scala.collection.immutable.Map<String,String>> partialSpec)
db
- (undocumented)table
- (undocumented)partialSpec
- (undocumented)scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> getPartitions(org.apache.spark.sql.catalyst.catalog.CatalogTable catalogTable, scala.Option<scala.collection.immutable.Map<String,String>> partialSpec)
catalogTable
- (undocumented)partialSpec
- (undocumented)scala.collection.Seq<org.apache.spark.sql.catalyst.catalog.CatalogTablePartition> getPartitionsByFilter(org.apache.spark.sql.catalyst.catalog.CatalogTable catalogTable, scala.collection.Seq<org.apache.spark.sql.catalyst.expressions.Expression> predicates)
Object getState()
HiveClientImpl
Any
not SessionState to avoid linkage errororg.apache.spark.sql.catalyst.catalog.CatalogTable getTable(String dbName, String tableName)
scala.Option<org.apache.spark.sql.catalyst.catalog.CatalogTable> getTableOption(String dbName, String tableName)
scala.collection.Seq<String> listDatabases(String pattern)
scala.collection.Seq<String> listFunctions(String db, String pattern)
scala.collection.Seq<String> listTables(String dbName)
scala.collection.Seq<String> listTables(String dbName, String pattern)
void loadDynamicPartitions(String loadPath, String dbName, String tableName, java.util.LinkedHashMap<String,String> partSpec, boolean replace, int numDP)
void loadPartition(String loadPath, String dbName, String tableName, java.util.LinkedHashMap<String,String> partSpec, boolean replace, boolean inheritTableSpecs, boolean isSrcLocal)
void loadTable(String loadPath, String tableName, boolean replace, boolean isSrcLocal)
HiveClient newSession()
HiveClient
as new session, that will share the class loader and Hive clientvoid renameFunction(String db, String oldName, String newName)
void renamePartitions(String db, String table, scala.collection.Seq<scala.collection.immutable.Map<String,String>> specs, scala.collection.Seq<scala.collection.immutable.Map<String,String>> newSpecs)
db
- (undocumented)table
- (undocumented)specs
- (undocumented)newSpecs
- (undocumented)void reset()
scala.collection.Seq<String> runSqlHive(String sql)
sql
- (undocumented)void setCurrentDatabase(String databaseName)
void setError(java.io.PrintStream stream)
void setInfo(java.io.PrintStream stream)
void setOut(java.io.PrintStream stream)
boolean tableExists(String dbName, String tableName)
org.apache.spark.sql.hive.client.HiveVersion version()
<A> A withHiveState(scala.Function0<A> f)