use of org.apache.hadoop.hive.metastore.api.AggrStats in project hive by apache.
the class TestHiveMetaStore method testStatsFastTrivial.
// Tests that in the absence of stats for partitions, and/or absence of columns
// to get stats for, the metastore does not break. See HIVE-12083 for motivation.
@Test
public void testStatsFastTrivial() throws Throwable {
String dbName = "tstatsfast";
String tblName = "t1";
String tblOwner = "statstester";
String typeName = "Person";
int lastAccessed = 12083;
cleanUp(dbName, tblName, typeName);
List<List<String>> values = new ArrayList<>();
values.add(makeVals("2008-07-01 14:13:12", "14"));
values.add(makeVals("2008-07-01 14:13:12", "15"));
values.add(makeVals("2008-07-02 14:13:12", "15"));
values.add(makeVals("2008-07-03 14:13:12", "151"));
createMultiPartitionTableSchema(dbName, tblName, typeName, values);
List<String> emptyColNames = new ArrayList<>();
List<String> emptyPartNames = new ArrayList<>();
List<String> colNames = new ArrayList<>();
colNames.add("name");
colNames.add("income");
List<String> partNames = client.listPartitionNames(dbName, tblName, (short) -1);
assertEquals(0, emptyColNames.size());
assertEquals(0, emptyPartNames.size());
assertEquals(2, colNames.size());
assertEquals(4, partNames.size());
// Test for both colNames and partNames being empty:
AggrStats aggrStatsEmpty = client.getAggrColStatsFor(dbName, tblName, emptyColNames, emptyPartNames, ENGINE);
// short-circuited on client-side, verifying that it's an empty object, not null
assertNotNull(aggrStatsEmpty);
assertEquals(0, aggrStatsEmpty.getPartsFound());
assertNotNull(aggrStatsEmpty.getColStats());
assert (aggrStatsEmpty.getColStats().isEmpty());
// Test for only colNames being empty
AggrStats aggrStatsOnlyParts = client.getAggrColStatsFor(dbName, tblName, emptyColNames, partNames, ENGINE);
// short-circuited on client-side, verifying that it's an empty object, not null
assertNotNull(aggrStatsOnlyParts);
assertEquals(0, aggrStatsOnlyParts.getPartsFound());
assertNotNull(aggrStatsOnlyParts.getColStats());
assert (aggrStatsOnlyParts.getColStats().isEmpty());
// Test for only partNames being empty
AggrStats aggrStatsOnlyCols = client.getAggrColStatsFor(dbName, tblName, colNames, emptyPartNames, ENGINE);
// short-circuited on client-side, verifying that it's an empty object, not null
assertNotNull(aggrStatsOnlyCols);
assertEquals(0, aggrStatsOnlyCols.getPartsFound());
assertNotNull(aggrStatsOnlyCols.getColStats());
assert (aggrStatsOnlyCols.getColStats().isEmpty());
// Test for valid values for both.
AggrStats aggrStatsFull = client.getAggrColStatsFor(dbName, tblName, colNames, partNames, ENGINE);
assertNotNull(aggrStatsFull);
// would still be empty, because no stats are actually populated.
assertEquals(0, aggrStatsFull.getPartsFound());
assertNotNull(aggrStatsFull.getColStats());
assert (aggrStatsFull.getColStats().isEmpty());
}
use of org.apache.hadoop.hive.metastore.api.AggrStats in project hive by apache.
the class ObjectStore method get_aggr_stats_for.
@Override
public AggrStats get_aggr_stats_for(String catName, String dbName, String tblName, final List<String> partNames, final List<String> colNames, String engine) throws MetaException, NoSuchObjectException {
final boolean useDensityFunctionForNDVEstimation = MetastoreConf.getBoolVar(getConf(), ConfVars.STATS_NDV_DENSITY_FUNCTION);
final double ndvTuner = MetastoreConf.getDoubleVar(getConf(), ConfVars.STATS_NDV_TUNER);
final boolean enableBitVector = MetastoreConf.getBoolVar(getConf(), ConfVars.STATS_FETCH_BITVECTOR);
return new GetHelper<AggrStats>(catName, dbName, tblName, true, false) {
@Override
protected AggrStats getSqlResult(GetHelper<AggrStats> ctx) throws MetaException {
return directSql.aggrColStatsForPartitions(catName, dbName, tblName, partNames, colNames, engine, useDensityFunctionForNDVEstimation, ndvTuner, enableBitVector);
}
@Override
protected AggrStats getJdoResult(GetHelper<AggrStats> ctx) throws MetaException, NoSuchObjectException {
// directSql, do it. No point in failing back to slow path here.
throw new MetaException("Jdo path is not implemented for stats aggr.");
}
@Override
protected String describeResult() {
return null;
}
}.run(true);
}
Aggregations