From 5232660b209c5b5d1107d22eebfacedfde4bcd67 Mon Sep 17 00:00:00 2001 From: chenhao16 Date: Mon, 4 Sep 2017 19:09:42 +0800 Subject: [PATCH 1/2] remove distinct check with one param in second aggregate pharse --- fe/src/com/baidu/palo/analysis/AggregateInfo.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/fe/src/com/baidu/palo/analysis/AggregateInfo.java b/fe/src/com/baidu/palo/analysis/AggregateInfo.java index e04b24ccdae8f2..c0db99e9241210 100644 --- a/fe/src/com/baidu/palo/analysis/AggregateInfo.java +++ b/fe/src/com/baidu/palo/analysis/AggregateInfo.java @@ -528,8 +528,6 @@ private void createSecondPhaseAggInfo( // SUM(DISTINCT ) -> SUM(); // (MIN(DISTINCT ...) and MAX(DISTINCT ...) have their DISTINCT turned // off during analysis, and AVG() is changed to SUM()/COUNT()) - Preconditions.checkState( - inputExpr.getFnName().getFunction().equalsIgnoreCase("SUM")); Expr aggExprParam = new SlotRef(inputDesc.getSlots().get(origGroupingExprs.size())); aggExpr = new FunctionCallExpr(inputExpr.getFnName(), Lists.newArrayList(aggExprParam)); } From c477e5b4dcc0d049932c61fa86a7808189fc39e8 Mon Sep 17 00:00:00 2001 From: chenhao16 Date: Tue, 5 Sep 2017 16:04:49 +0800 Subject: [PATCH 2/2] select wrong rollup --- fe/src/com/baidu/palo/alter/RollupJob.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/fe/src/com/baidu/palo/alter/RollupJob.java b/fe/src/com/baidu/palo/alter/RollupJob.java index 6db03cfacd1683..467f42766bc6c4 100644 --- a/fe/src/com/baidu/palo/alter/RollupJob.java +++ b/fe/src/com/baidu/palo/alter/RollupJob.java @@ -624,6 +624,7 @@ public int tryFinishJob() { MaterializedIndex rollupIndex = this.partitionIdToRollupIndex.get(partitionId); Preconditions.checkNotNull(rollupIndex); + long rollupRowCount = 0L; // 1. record replica info for (Tablet tablet : rollupIndex.getTablets()) { long tabletId = tablet.getId(); @@ -634,8 +635,21 @@ public int tryFinishJob() { replica.getDataSize(), replica.getRowCount()); this.partitionIdToReplicaInfos.put(partitionId, replicaInfo); } + + // calculate rollup index row count + long tabletRowCount = 0L; + for (Replica replica : tablet.getReplicas()) { + long replicaRowCount = replica.getRowCount(); + if (replicaRowCount > tabletRowCount) { + tabletRowCount = replicaRowCount; + } + } + rollupRowCount += tabletRowCount; + } // end for tablets + rollupIndex.setRowCount(rollupRowCount); + // 2. add to partition partition.createRollupIndex(rollupIndex); @@ -717,11 +731,24 @@ public void unprotectedReplayFinish(Database db) { Partition partition = olapTable.getPartition(partitionId); MaterializedIndex rollupIndex = entry.getValue(); + long rollupRowCount = 0L; for (Tablet tablet : rollupIndex.getTablets()) { for (Replica replica : tablet.getReplicas()) { replica.setState(ReplicaState.NORMAL); } + + // calculate rollup index row count + long tabletRowCount = 0L; + for (Replica replica : tablet.getReplicas()) { + long replicaRowCount = replica.getRowCount(); + if (replicaRowCount > tabletRowCount) { + tabletRowCount = replicaRowCount; + } + } + rollupRowCount += tabletRowCount; } + + rollupIndex.setRowCount(rollupRowCount); rollupIndex.setState(IndexState.NORMAL); MaterializedIndex baseIndex = partition.getIndex(baseIndexId);