Search in sources :

Example 21 with Function

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

Example 22 with Function

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

Example 23 with Function

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

Example 24 with 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());
    }
}
Also used : Function(org.apache.hadoop.hive.metastore.api.Function) ResourceUri(org.apache.hadoop.hive.metastore.api.ResourceUri) DatabaseBuilder(org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder) FunctionBuilder(org.apache.hadoop.hive.metastore.client.builder.FunctionBuilder) Before(org.junit.Before)

Example 25 with Function

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);
}
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)69 Test (org.junit.Test)47 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)38 ResourceUri (org.apache.hadoop.hive.metastore.api.ResourceUri)17 TTransportException (org.apache.thrift.transport.TTransportException)11 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)9 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)8 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)6 FunctionBuilder (org.apache.hadoop.hive.metastore.client.builder.FunctionBuilder)6 Database (org.apache.hadoop.hive.metastore.api.Database)4 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)4 TApplicationException (org.apache.thrift.TApplicationException)4 TException (org.apache.thrift.TException)4 HashSet (java.util.HashSet)3 Path (org.apache.hadoop.fs.Path)3 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)3 Partition (org.apache.hadoop.hive.metastore.api.Partition)3 SQLException (java.sql.SQLException)2