Search in sources :

Example 76 with Function

use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.

the class TestFunctions method testCreateFunctionCaseInsensitive.

@Test
public void testCreateFunctionCaseInsensitive() throws Exception {
    Function function = testFunctions[0];
    function.setFunctionName("Test_Upper_Case_Func_Name");
    client.createFunction(function);
    String storedName = client.getFunction(function.getDbName(), function.getFunctionName()).getFunctionName();
    Assert.assertEquals(function.getFunctionName().toLowerCase(), storedName);
}
Also used : Function(org.apache.hadoop.hive.metastore.api.Function) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 77 with Function

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);
}
Also used : Function(org.apache.hadoop.hive.metastore.api.Function) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 78 with Function

use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.

the class TestFunctions method testDropFunctionCaseInsensitive.

@Test
public void testDropFunctionCaseInsensitive() throws Exception {
    Function function = testFunctions[0];
    // Test in upper case
    client.dropFunction(function.getDbName().toUpperCase(), function.getFunctionName().toUpperCase());
    // Check if the function is really removed
    try {
        client.getFunction(function.getDbName(), function.getFunctionName());
        Assert.fail("Expected a NoSuchObjectException to be thrown");
    } catch (NoSuchObjectException exception) {
    // Expected exception
    }
    // Test in mixed case
    client.createFunction(function);
    client.dropFunction("DeFaUlt", "tEsT_FuncTION_tO_FinD_1");
    // Check if the function is really removed
    try {
        client.getFunction(function.getDbName(), function.getFunctionName());
        Assert.fail("Expected a NoSuchObjectException to be thrown");
    } catch (NoSuchObjectException exception) {
    // Expected exception
    }
}
Also used : Function(org.apache.hadoop.hive.metastore.api.Function) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 79 with Function

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);
}
Also used : Function(org.apache.hadoop.hive.metastore.api.Function) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 80 with Function

use of org.apache.hadoop.hive.metastore.api.Function in project hive by apache.

the class TestFunctions method testCreateFunctionEmptyName.

@Test(expected = InvalidObjectException.class)
public void testCreateFunctionEmptyName() throws Exception {
    Function function = testFunctions[0];
    function.setFunctionName("");
    client.createFunction(function);
}
Also used : Function(org.apache.hadoop.hive.metastore.api.Function) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

Function (org.apache.hadoop.hive.metastore.api.Function)90 Test (org.junit.Test)54 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)40 ResourceUri (org.apache.hadoop.hive.metastore.api.ResourceUri)22 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)13 ArrayList (java.util.ArrayList)12 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)11 IOException (java.io.IOException)10 FunctionBuilder (org.apache.hadoop.hive.metastore.client.builder.FunctionBuilder)9 Database (org.apache.hadoop.hive.metastore.api.Database)7 HashSet (java.util.HashSet)6 Path (org.apache.hadoop.fs.Path)6 TException (org.apache.thrift.TException)6 HiveConf (org.apache.hadoop.hive.conf.HiveConf)5 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)4 Partition (org.apache.hadoop.hive.metastore.api.Partition)4 Before (org.junit.Before)4 List (java.util.List)3 FunctionType (org.apache.hadoop.hive.metastore.api.FunctionType)3 GetAllFunctionsResponse (org.apache.hadoop.hive.metastore.api.GetAllFunctionsResponse)3