use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testCreateGetDeleteFunction.
/**
* This test creates and queries a function and then drops it. Good for testing the happy path.
*/
@Test
public void testCreateGetDeleteFunction() throws Exception {
Function function = new FunctionBuilder().setDbName(OTHER_DATABASE).setName("test_function").setClass(TEST_FUNCTION_CLASS).setFunctionType(FunctionType.JAVA).setOwnerType(PrincipalType.ROLE).setOwner("owner").setCreateTime(100).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")).create(client, metaStore.getConf());
Function createdFunction = client.getFunction(function.getDbName(), function.getFunctionName());
// The createTime will be set on the server side, so the comparison should skip it
function.setCreateTime(createdFunction.getCreateTime());
Assert.assertEquals("Comparing functions", function, createdFunction);
client.dropFunction(function.getDbName(), function.getFunctionName());
try {
client.getFunction(function.getDbName(), function.getFunctionName());
Assert.fail("Expected a NoSuchObjectException to be thrown");
} catch (NoSuchObjectException exception) {
// Expected exception
}
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testDropFunctionNoSuchDatabase.
@Test(expected = NoSuchObjectException.class)
public void testDropFunctionNoSuchDatabase() throws Exception {
// Choosing the 2nd function, since the 1st one is duplicated in the dummy database
Function function = testFunctions[1];
client.dropFunction("no_such_database", function.getFunctionName());
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testGetFunctionNoSuchFunction.
@Test(expected = NoSuchObjectException.class)
public void testGetFunctionNoSuchFunction() throws Exception {
// Choosing the 2nd function, since the 1st one is duplicated in the dummy database
Function function = testFunctions[1];
client.getFunction(function.getDbName(), "no_such_function");
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionEmptyNameInNew.
@Test(expected = MetaException.class)
public void testAlterFunctionEmptyNameInNew() throws Exception {
Function newFunction = getNewFunction();
newFunction.setFunctionName("");
client.alterFunction(DEFAULT_DATABASE, "test_function_to_find_2", newFunction);
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionInvalidNameInNew.
@Test(expected = MetaException.class)
public void testAlterFunctionInvalidNameInNew() throws Exception {
Function newFunction = getNewFunction();
newFunction.setFunctionName("test_function_2;");
client.alterFunction(DEFAULT_DATABASE, "test_function_to_find_2", newFunction);
}
Aggregations