use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testGetAllFunctions.
@Test
public void testGetAllFunctions() throws Exception {
GetAllFunctionsResponse response = client.getAllFunctions();
List<Function> allFunctions = response.getFunctions();
Assert.assertEquals("All functions size", 4, allFunctions.size());
for (Function function : allFunctions) {
if (function.getDbName().equals(OTHER_DATABASE)) {
Assert.assertEquals("Comparing functions", testFunctions[3], function);
} else if (function.getFunctionName().equals("test_function_hidden_1")) {
Assert.assertEquals("Comparing functions", testFunctions[2], function);
} else if (function.getFunctionName().equals("test_function_to_find_2")) {
Assert.assertEquals("Comparing functions", testFunctions[1], function);
} else {
Assert.assertEquals("Comparing functions", testFunctions[0], function);
}
}
// Drop one function, see what remains
client.dropFunction(testFunctions[1].getDbName(), testFunctions[1].getFunctionName());
response = client.getAllFunctions();
allFunctions = response.getFunctions();
Assert.assertEquals("All functions size", 3, allFunctions.size());
for (Function function : allFunctions) {
if (function.getDbName().equals(OTHER_DATABASE)) {
Assert.assertEquals("Comparing functions", testFunctions[3], function);
} else if (function.getFunctionName().equals("test_function_hidden_1")) {
Assert.assertEquals("Comparing functions", testFunctions[2], function);
} else {
Assert.assertEquals("Comparing functions", testFunctions[0], function);
}
}
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionNullOwnerTypeInNew.
@Test
public void testAlterFunctionNullOwnerTypeInNew() throws Exception {
Function newFunction = getNewFunction();
newFunction.setOwnerType(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 testCreateFunctionDefaultValues.
@Test
public void testCreateFunctionDefaultValues() throws Exception {
Function function = new Function();
function.setDbName(OTHER_DATABASE);
function.setFunctionName("test_function");
function.setClassName(TEST_FUNCTION_CLASS);
function.setOwnerType(PrincipalType.USER);
function.setFunctionType(FunctionType.JAVA);
client.createFunction(function);
Function createdFunction = client.getFunction(function.getDbName(), function.getFunctionName());
Assert.assertNull("Comparing OwnerName", createdFunction.getOwnerName());
Assert.assertEquals("Comparing ResourceUris", 0, createdFunction.getResourceUris().size());
// The create time is set
Assert.assertNotEquals("Comparing CreateTime", 0, createdFunction.getCreateTime());
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testGetFunctionCaseInsensitive.
@Test
public void testGetFunctionCaseInsensitive() throws Exception {
Function function = testFunctions[0];
// Test in upper case
Function resultUpper = client.getFunction(function.getDbName().toUpperCase(), function.getFunctionName().toUpperCase());
Assert.assertEquals("Comparing functions", function, resultUpper);
// Test in mixed case
Function resultMix = client.getFunction("DeFaUlt", "tEsT_FuncTION_tO_FinD_1");
Assert.assertEquals("Comparing functions", function, resultMix);
}
use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.
the class TestFunctions method testAlterFunctionNullFunction.
@Test
public void testAlterFunctionNullFunction() throws Exception {
Function originalFunction = testFunctions[1];
try {
client.alterFunction(DEFAULT_DATABASE, originalFunction.getFunctionName(), null);
// 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