use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionNoSuchFunctionInThisDatabase.
@Test(expected = MetaException.class)
public void testAlterFunctionNoSuchFunctionInThisDatabase() throws Exception {
// Choosing the 2nd function, since the 1st one is duplicated in the dummy database
Function originalFunction = testFunctions[1];
Function newFunction = getNewFunction();
client.alterFunction(OTHER_DATABASE, originalFunction.getFunctionName(), newFunction);
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionNullFunctionNameInNew.
@Test
public void testAlterFunctionNullFunctionNameInNew() throws Exception {
Function newFunction = getNewFunction();
newFunction.setFunctionName(null);
try {
client.alterFunction(DEFAULT_DATABASE, "test_function_to_find_2", newFunction);
// TODO: Should have a check on the server side. Embedded metastore throws
// NullPointerException, remote throws TTransportException
Assert.fail("Expected an NullPointerException or TTransportException to be thrown");
} catch (NullPointerException exception) {
// Expected exception - Embedded MetaStore
} catch (TTransportException exception) {
// Expected exception - Remote MetaStore
}
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testCreateFunctionNoSuchDatabase.
@Test(expected = NoSuchObjectException.class)
public void testCreateFunctionNoSuchDatabase() throws Exception {
Function function = testFunctions[0];
function.setDbName("no_such_database");
client.createFunction(function);
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method setUp.
@Before
public void setUp() throws Exception {
// Get new client
client = metaStore.getClient();
// Clean up the database
client.dropDatabase(OTHER_DATABASE, true, true, true);
for (Function function : client.getAllFunctions().getFunctions()) {
client.dropFunction(function.getDbName(), function.getFunctionName());
}
testFunctions[0] = new FunctionBuilder().setDbName(DEFAULT_DATABASE).setName("test_function_to_find_1").setClass(TEST_FUNCTION_CLASS).addResourceUri(new ResourceUri(ResourceType.JAR, "hdfs:///tmp/jar1.jar")).addResourceUri(new ResourceUri(ResourceType.FILE, "hdfs:///tmp/file1.txt")).addResourceUri(new ResourceUri(ResourceType.ARCHIVE, "hdfs:///tmp/archive1.tgz")).build();
testFunctions[1] = new FunctionBuilder().setDbName(DEFAULT_DATABASE).setName("test_function_to_find_2").setClass(TEST_FUNCTION_CLASS).build();
testFunctions[2] = new FunctionBuilder().setDbName(DEFAULT_DATABASE).setName("test_function_hidden_1").setClass(TEST_FUNCTION_CLASS).build();
client.createDatabase(new DatabaseBuilder().setName(OTHER_DATABASE).build());
testFunctions[3] = new FunctionBuilder().setDbName(OTHER_DATABASE).setName("test_function_to_find_1").setClass(TEST_FUNCTION_CLASS).build();
// Create the functions, and reload them from the MetaStore
for (int i = 0; i < testFunctions.length; i++) {
client.createFunction(testFunctions[i]);
testFunctions[i] = client.getFunction(testFunctions[i].getDbName(), testFunctions[i].getFunctionName());
}
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionNoSuchFunction.
@Test(expected = MetaException.class)
public void testAlterFunctionNoSuchFunction() throws Exception {
// Choosing the 2nd function, since the 1st one is duplicated in the dummy database
Function originalFunction = testFunctions[1];
Function newFunction = getNewFunction();
client.alterFunction(originalFunction.getDbName(), "no_such_function", newFunction);
}
Aggregations