Search in sources :

Example 1 with PartitionsByExprRequest

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

the class TestMetastoreExpr method checkExpr.

public void checkExpr(int numParts, String dbName, String tblName, ExprNodeGenericFuncDesc expr, Table t) throws Exception {
    List<Partition> parts = new ArrayList<Partition>();
    client.listPartitionsByExpr(dbName, tblName, SerializationUtilities.serializeExpressionToKryo(expr), null, (short) -1, parts);
    assertEquals("Partition check failed: " + expr.getExprString(), numParts, parts.size());
    // check with partition spec as well
    PartitionsByExprRequest req = new PartitionsByExprRequest(dbName, tblName, ByteBuffer.wrap(SerializationUtilities.serializeExpressionToKryo(expr)));
    req.setMaxParts((short) -1);
    req.setId(t.getId());
    List<PartitionSpec> partSpec = new ArrayList<>();
    client.listPartitionsSpecByExpr(req, partSpec);
    int partSpecSize = 0;
    if (!partSpec.isEmpty()) {
        partSpecSize = partSpec.iterator().next().getSharedSDPartitionSpec().getPartitionsSize();
    }
    assertEquals("Partition Spec check failed: " + expr.getExprString(), numParts, partSpecSize);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionsByExprRequest(org.apache.hadoop.hive.metastore.api.PartitionsByExprRequest) ArrayList(java.util.ArrayList) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec)

Example 2 with PartitionsByExprRequest

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

the class TestSessionHiveMetastoreClientListPartitionsTempTable method testListPartitionsSpecByExprNoDb.

@Test(expected = NoSuchObjectException.class)
public void testListPartitionsSpecByExprNoDb() throws Exception {
    getClient().dropDatabase(DB_NAME);
    PartitionsByExprRequest req = new PartitionsByExprRequest(DB_NAME, TABLE_NAME, ByteBuffer.wrap(new byte[] { 'f', 'o', 'o' }));
    req.setMaxParts((short) -1);
    getClient().listPartitionsSpecByExpr(req, null);
}
Also used : PartitionsByExprRequest(org.apache.hadoop.hive.metastore.api.PartitionsByExprRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 3 with PartitionsByExprRequest

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

the class TestSessionHiveMetastoreClientListPartitionsTempTable method testListPartitionsSpecByExprEmptyTblName.

@Test(expected = NoSuchObjectException.class)
public void testListPartitionsSpecByExprEmptyTblName() throws Exception {
    Table t = createTable3PartCols1Part(getClient());
    PartitionsByExprRequest req = new PartitionsByExprRequest(DB_NAME, "", ByteBuffer.wrap(new byte[] { 'f', 'o', 'o' }));
    req.setMaxParts((short) -1);
    req.setId(t.getId());
    getClient().listPartitionsSpecByExpr(req, new ArrayList<>());
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) PartitionsByExprRequest(org.apache.hadoop.hive.metastore.api.PartitionsByExprRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 4 with PartitionsByExprRequest

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

the class TestSessionHiveMetastoreClientListPartitionsTempTable method testListPartitionsSpecByExprDefMaxParts.

@Test
public void testListPartitionsSpecByExprDefMaxParts() throws Exception {
    Table t = createTable4PartColsParts(getClient()).table;
    TestMetastoreExpr.ExprBuilder e = new TestMetastoreExpr.ExprBuilder(TABLE_NAME);
    List<PartitionSpec> result = new ArrayList<>();
    PartitionsByExprRequest req = new PartitionsByExprRequest(DB_NAME, TABLE_NAME, ByteBuffer.wrap(SerializationUtilities.serializeExpressionToKryo(e.strCol("yyyy").val("2017").pred(">=", 2).build())));
    req.setMaxParts((short) 3);
    req.setId(t.getId());
    getClient().listPartitionsSpecByExpr(req, result);
    assertEquals(3, result.iterator().next().getSharedSDPartitionSpec().getPartitionsSize());
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) PartitionsByExprRequest(org.apache.hadoop.hive.metastore.api.PartitionsByExprRequest) ArrayList(java.util.ArrayList) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec) TestMetastoreExpr(org.apache.hadoop.hive.metastore.TestMetastoreExpr) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 5 with PartitionsByExprRequest

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

the class TestSessionHiveMetastoreClientListPartitionsTempTable method checkExprPartitionSpec.

private void checkExprPartitionSpec(int numParts, ExprNodeGenericFuncDesc expr, Table t) throws Exception {
    List<Partition> parts = new ArrayList<>();
    getClient().listPartitionsByExpr(DB_NAME, TABLE_NAME, SerializationUtilities.serializeExpressionToKryo(expr), null, (short) -1, parts);
    assertEquals("Partition check failed: " + expr.getExprString(), numParts, parts.size());
    // check with partition spec as well
    PartitionsByExprRequest req = new PartitionsByExprRequest(DB_NAME, TABLE_NAME, ByteBuffer.wrap(SerializationUtilities.serializeExpressionToKryo(expr)));
    req.setMaxParts((short) -1);
    req.setId(t.getId());
    List<PartitionSpec> partSpec = new ArrayList<>();
    getClient().listPartitionsSpecByExpr(req, partSpec);
    int partSpecSize = 0;
    if (!partSpec.isEmpty()) {
        partSpecSize = partSpec.iterator().next().getSharedSDPartitionSpec().getPartitionsSize();
    }
    assertEquals("Partition Spec check failed: " + expr.getExprString(), numParts, partSpecSize);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionsByExprRequest(org.apache.hadoop.hive.metastore.api.PartitionsByExprRequest) ArrayList(java.util.ArrayList) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec)

Aggregations

PartitionsByExprRequest (org.apache.hadoop.hive.metastore.api.PartitionsByExprRequest)16 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)6 PartitionSpec (org.apache.hadoop.hive.metastore.api.PartitionSpec)5 Table (org.apache.hadoop.hive.metastore.api.Table)5 TestMetastoreExpr (org.apache.hadoop.hive.metastore.TestMetastoreExpr)3 Partition (org.apache.hadoop.hive.metastore.api.Partition)3 ValidWriteIdList (org.apache.hadoop.hive.common.ValidWriteIdList)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)2 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 ExecutionException (java.util.concurrent.ExecutionException)1 JDODataStoreException (javax.jdo.JDODataStoreException)1 HiveMetaException (org.apache.hadoop.hive.metastore.HiveMetaException)1 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)1 DropPartitionsExpr (org.apache.hadoop.hive.metastore.api.DropPartitionsExpr)1 DropPartitionsResult (org.apache.hadoop.hive.metastore.api.DropPartitionsResult)1