@Override public int process(Hive db, Table tbl) throws Exception { return persistColumnStats(db, tbl); }
ColumnStatisticsDesc statsDesc = buildColumnStatsDesc(tbl, partName, isTblLevel); ColumnStatistics colStats = new ColumnStatistics(); colStats.setStatsDesc(statsDesc);
@Override public void initialize(QueryState queryState, QueryPlan queryPlan, DriverContext ctx, CompilationOpContext opContext) { super.initialize(queryState, queryPlan, ctx, opContext); if (work.getBasicStatsWork() != null) { BasicStatsTask task = new BasicStatsTask(conf, work.getBasicStatsWork()); task.followedColStats = work.hasColStats(); processors.add(0, task); } else if (work.isFooterScan()) { BasicStatsNoJobTask t = new BasicStatsNoJobTask(conf, work.getBasicStatsNoJobWork()); processors.add(0, t); } if (work.hasColStats()) { processors.add(new ColStatsProcessor(work.getColStats(), conf)); } for (IStatsProcessor p : processors) { p.initialize(opContext); } }
public int persistColumnStats(Hive db, Table tbl) throws HiveException, MetaException, IOException { // Construct a column statistics object from the result List<ColumnStatistics> colStats = constructColumnStatsFromPackedRows(tbl); // Persist the column statistics object to the metastore // Note, this function is shared for both table and partition column stats. if (colStats.isEmpty()) { return 0; } SetPartitionsStatsRequest request = new SetPartitionsStatsRequest(colStats); request.setNeedMerge(colStatDesc.isNeedMerge()); HiveTxnManager txnMgr = AcidUtils.isTransactionalTable(tbl) ? SessionState.get().getTxnMgr() : null; if (txnMgr != null) { request.setValidWriteIdList(AcidUtils.getTableValidWriteIdList(conf, AcidUtils.getFullTableName(tbl.getDbName(), tbl.getTableName())).toString()); request.setWriteId(txnMgr.getAllocatedTableWriteId(tbl.getDbName(), tbl.getTableName())); } db.setPartitionColumnStatistics(request); return 0; }