morrySnow commented on code in PR #13883: URL: https://github.com/apache/doris/pull/13883#discussion_r1018032483
########## fe/fe-core/src/test/java/org/apache/doris/cluster/DecommissionBackendTest.java: ########## @@ -83,7 +83,7 @@ public void testDecommissionBackend() throws Exception { } Assertions.assertEquals(backendNum() - 1, Env.getCurrentSystemInfo().getIdToBackend().size()); - Assertions.assertEquals(tabletNum, Env.getCurrentInvertedIndex().getTabletMetaMap().size()); + Assertions.assertEquals(tabletNum + 14, Env.getCurrentInvertedIndex().getTabletMetaMap().size()); Review Comment: 14 is a magic number, add a local variable plz ########## fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java: ########## @@ -351,55 +350,52 @@ private StatsDeriveResult computeAggregate(Aggregate aggregate) { // TODO: do real project on column stats private StatsDeriveResult computeProject(Project project) { List<NamedExpression> projections = project.getProjects(); - StatsDeriveResult statsDeriveResult = groupExpression.getCopyOfChildStats(0); - Map<Slot, ColumnStat> childColumnStats = statsDeriveResult.getSlotToColumnStats(); - Map<Slot, ColumnStat> columnsStats = projections.stream().map(projection -> { - ColumnStat value = null; + StatsDeriveResult statsDeriveResult = groupExpression.childStatistics(0); + Map<Id, ColumnStatistic> childColumnStats = statsDeriveResult.getSlotIdToColumnStats(); + Map<Id, ColumnStatistic> columnsStats = projections.stream().map(projection -> { + ColumnStatistic value = null; Set<Slot> slots = projection.getInputSlots(); if (slots.isEmpty()) { - value = ColumnStat.createDefaultColumnStats(); + value = ColumnStatistic.DEFAULT; } else { // TODO: just a trick here, need to do real project on column stats for (Slot slot : slots) { - if (childColumnStats.containsKey(slot)) { - value = childColumnStats.get(slot); + if (childColumnStats.containsKey(slot.getExprId())) { + value = childColumnStats.get(slot.getExprId()); break; } } if (value == null) { - value = ColumnStat.createDefaultColumnStats(); + value = ColumnStatistic.DEFAULT; } } - return new SimpleEntry<>(projection.toSlot(), value); + return new SimpleEntry<>(projection.toSlot().getExprId(), value); }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (item1, item2) -> item1)); - statsDeriveResult.setSlotToColumnStats(columnsStats); - return statsDeriveResult; + return new StatsDeriveResult(statsDeriveResult.getRowCount(), columnsStats); } private StatsDeriveResult computeOneRowRelation(OneRowRelation oneRowRelation) { - Map<Slot, ColumnStat> columnStatsMap = oneRowRelation.getProjects() + Map<Id, ColumnStatistic> columnStatsMap = oneRowRelation.getProjects() .stream() .map(project -> { - ColumnStat columnStats = new ColumnStat(); - columnStats.setNdv(1); + ColumnStatistic statistic = new ColumnStatisticBuilder().setNdv(1).createColumnStatistic(); // TODO: compute the literal size - return Pair.of(project.toSlot(), columnStats); + return Pair.of(project.toSlot().getExprId(), statistic); }) .collect(Collectors.toMap(Pair::key, Pair::value)); int rowCount = 1; return new StatsDeriveResult(rowCount, columnStatsMap); } private StatsDeriveResult computeEmptyRelation(EmptyRelation emptyRelation) { - Map<Slot, ColumnStat> columnStatsMap = emptyRelation.getProjects() + Map<Id, ColumnStatistic> columnStatsMap = emptyRelation.getProjects() .stream() .map(project -> { - ColumnStat columnStats = new ColumnStat(); - columnStats.setNdv(0); - columnStats.setMaxSizeByte(0); - columnStats.setNumNulls(0); - columnStats.setAvgSizeByte(0); - return Pair.of(project.toSlot(), columnStats); + ColumnStatisticBuilder builder = new ColumnStatisticBuilder() + .setNdv(0) + .setNumNulls(0) + .setAvgSizeByte(0); + return Pair.of(project.toSlot().getExprId(), builder.createColumnStatistic()); Review Comment: rename `createColumnStatistic` to `build` ########## fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java: ########## @@ -449,6 +449,7 @@ public static List<TSchemaTableStructure> getTableStructure(String tableName) { return tSchemaTableStructureList; } + Review Comment: redundant white line -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org