fix scala group by remove by transformer
This commit is contained in:
@ -1737,7 +1737,9 @@ int ObDMLStmt::formalize_stmt_expr_reference()
|
||||
} else { /*do nothing*/ }
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(remove_useless_sharable_expr())) {
|
||||
if (is_select_stmt() && OB_FAIL(static_cast<ObSelectStmt*>(this)->maintain_scala_group_by_ref())) {
|
||||
LOG_WARN("failed to meantain scala group by", K(ret));
|
||||
} else if (OB_FAIL(remove_useless_sharable_expr())) {
|
||||
LOG_WARN("failed to remove useless sharable expr", K(ret));
|
||||
} else if (OB_FAIL(check_pseudo_column_valid())) {
|
||||
LOG_WARN("failed to check pseudo column", K(ret));
|
||||
|
||||
@ -1305,3 +1305,28 @@ ObRawExpr* ObSelectStmt::get_pure_set_expr(ObRawExpr *expr)
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
// add ref count to the last aggr item to maintain the scala group by
|
||||
int ObSelectStmt::maintain_scala_group_by_ref()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool has_ref = false;
|
||||
if (is_scala_group_by()) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < agg_items_.count(); ++i) {
|
||||
ObAggFunRawExpr *agg_expr = agg_items_.at(i);
|
||||
if (OB_ISNULL(agg_expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("agg expr is NULL", K(ret));
|
||||
} else if (agg_expr->is_explicited_reference()) {
|
||||
has_ref = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret) || has_ref) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(set_sharable_expr_reference(*agg_items_.at(0), ExplicitedRefType::REF_BY_NORMAL))) {
|
||||
LOG_WARN("fail to set expr reference", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -438,6 +438,7 @@ public:
|
||||
bool has_hidden_rowid() const;
|
||||
virtual int clear_sharable_expr_reference() override;
|
||||
virtual int remove_useless_sharable_expr() override;
|
||||
int maintain_scala_group_by_ref();
|
||||
|
||||
const common::ObIArray<OrderItem>& get_search_by_items() const { return search_by_items_; }
|
||||
const common::ObIArray<ColumnItem>& get_cycle_items() const { return cycle_by_items_; }
|
||||
|
||||
Reference in New Issue
Block a user