use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testCreateFunctionInvalidName.
@Test(expected = InvalidObjectException.class)
public void testCreateFunctionInvalidName() throws Exception {
Function function = testFunctions[0];
function.setFunctionName("test_function_2;");
client.createFunction(function);
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionCaseInsensitive.
@Test
public void testAlterFunctionCaseInsensitive() throws Exception {
Function newFunction = new FunctionBuilder().setDbName(OTHER_DATABASE).setName("test_function_2").setClass(TEST_FUNCTION_CLASS).build();
Function originalFunction = testFunctions[1];
// Test in upper case
client.alterFunction(originalFunction.getDbName().toUpperCase(), originalFunction.getFunctionName().toUpperCase(), newFunction);
Function alteredFunction = client.getFunction(newFunction.getDbName(), newFunction.getFunctionName());
// The creation time is changed, so we do not check that
newFunction.setCreateTime(alteredFunction.getCreateTime());
Assert.assertEquals("Comparing functions", newFunction, alteredFunction);
try {
client.getFunction(originalFunction.getDbName(), originalFunction.getDbName());
Assert.fail("Expected a NoSuchObjectException to be thrown");
} catch (NoSuchObjectException exception) {
// Expected exception
}
// Test in mixed case
originalFunction = testFunctions[2];
newFunction.setFunctionName("test_function_3");
client.alterFunction("DeFaUlt", "tEsT_FuncTION_HiDDEn_1", newFunction);
alteredFunction = client.getFunction(newFunction.getDbName(), newFunction.getFunctionName());
// The creation time is changed, so we do not check that
newFunction.setCreateTime(alteredFunction.getCreateTime());
Assert.assertEquals("Comparing functions", newFunction, alteredFunction);
try {
client.getFunction(originalFunction.getDbName(), originalFunction.getDbName());
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 testCreateFunctionAlreadyExists.
@Test(expected = AlreadyExistsException.class)
public void testCreateFunctionAlreadyExists() throws Exception {
Function function = testFunctions[0];
client.createFunction(function);
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionEmptyNameInNew.
@Test
public void testAlterFunctionEmptyNameInNew() throws Exception {
Function newFunction = getNewFunction();
newFunction.setFunctionName("");
try {
client.alterFunction(DEFAULT_DATABASE, "test_function_to_find_2", newFunction);
// TODO: Should have a check on the server side. Embedded metastore throws
// InvalidObjectException, remote throws TApplicationException
Assert.fail("Expected an InvalidObjectException or TApplicationException to be thrown");
} catch (InvalidObjectException exception) {
// Expected exception - Embedded MetaStore
} catch (TApplicationException exception) {
// Expected exception - Remote MetaStore
}
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testCreateFunctionNullFunctionType.
@Test
public void testCreateFunctionNullFunctionType() throws Exception {
Function function = testFunctions[0];
function.setFunctionName("test_function_2");
function.setFunctionType(null);
try {
client.createFunction(function);
// 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
}
}
Aggregations