Skip to content

Commit

Permalink
do not push down agg on aggregate column (apache#27356)
Browse files Browse the repository at this point in the history
do not push down agg on aggregate column
  • Loading branch information
BiteTheDDDDt authored Nov 22, 2023
1 parent b821672 commit b541de7
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions be/src/olap/rowset/segment_v2/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ Status ColumnReader::get_row_ranges_by_zone_map(
}

Status ColumnReader::next_batch_of_zone_map(size_t* n, vectorized::MutableColumnPtr& dst) const {
if (_segment_zone_map == nullptr) {
return Status::InternalError("segment zonemap not exist");
}
// TODO: this work to get min/max value seems should only do once
FieldType type = _type_info->type();
std::unique_ptr<WrapperField> min_value(WrapperField::create_by_type(type, _meta_length));
Expand Down
5 changes: 0 additions & 5 deletions be/src/olap/rowset/segment_v2/zone_map_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ void TypedZoneMapIndexWriter<Type>::reset_page_zone_map() {
_page_zone_map.pass_all = true;
}

template <PrimitiveType Type>
void TypedZoneMapIndexWriter<Type>::reset_segment_zone_map() {
_segment_zone_map.pass_all = true;
}

template <PrimitiveType Type>
Status TypedZoneMapIndexWriter<Type>::flush() {
// Update segment zone map.
Expand Down
2 changes: 0 additions & 2 deletions be/src/olap/rowset/segment_v2/zone_map_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class ZoneMapIndexWriter {
virtual uint64_t size() const = 0;

virtual void reset_page_zone_map() = 0;
virtual void reset_segment_zone_map() = 0;
};

// Zone map index is represented by an IndexedColumn with ordinal index.
Expand All @@ -120,7 +119,6 @@ class TypedZoneMapIndexWriter final : public ZoneMapIndexWriter {
uint64_t size() const override { return _estimated_size; }

void reset_page_zone_map() override;
void reset_segment_zone_map() override;

private:
void _reset_zone_map(ZoneMap* zone_map) {
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/olap/vgeneric_iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Status VStatisticsIterator::next_batch(Block* block) {
}
} else {
for (int i = 0; i < block->columns(); ++i) {
static_cast<void>(_column_iterators[i]->next_batch_of_zone_map(&size, columns[i]));
RETURN_IF_ERROR(_column_iterators[i]->next_batch_of_zone_map(&size, columns[i]));
}
}
_output_rows += size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,8 @@ private LogicalAggregate<? extends Plan> storageLayerAggregate(

for (SlotReference slot : usedSlotInTable) {
Column column = slot.getColumn().get();
if (logicalScan instanceof LogicalOlapScan) {
KeysType keysType = ((LogicalOlapScan) logicalScan).getTable().getKeysType();
if (keysType == KeysType.AGG_KEYS && !column.isKey()) {
return canNotPush;
}
if (column.isAggregated()) {
return canNotPush;
}
// The zone map max length of CharFamily is 512, do not
// over the length: https://github.com/apache/doris/pull/6293
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,13 @@ public boolean pushDownAggNoGroupingCheckCol(FunctionCallExpr aggExpr, Column co
return false;
}

if (aggExpr.getChild(0) instanceof SlotRef) {
SlotRef slot = (SlotRef) aggExpr.getChild(0);
if (CreateMaterializedViewStmt.isMVColumn(slot.getColumnName()) && slot.getColumn().isAggregated()) {
return false;
}
}

return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ ASIA ASIA 1992 1
1 4 1 1
2 8 2 2

-- !select --
1 2

Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,5 @@ suite ("multiple_no_where") {
contains "(temp_2)"
}
qt_select_temp_2 """SELECT lo_orderkey, sum(lo_extendedprice),max(lo_extendedprice), min(lo_extendedprice) from lineorder_flat group by lo_orderkey order by lo_orderkey;"""
qt_select """ select min(lo_extendedprice),max(lo_extendedprice) from lineorder_flat;"""
}

0 comments on commit b541de7

Please sign in to comment.