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);
}
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);
}
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<>());
}
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());
}
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);
}
Aggregations