fix rollup correctness bug of wrong equal set
This commit is contained in:
@ -546,6 +546,33 @@ int ObLogGroupBy::compute_const_exprs()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogGroupBy::compute_equal_set()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
EqualSets *ordering_esets = NULL;
|
||||
if (OB_ISNULL(my_plan_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("operator is invalid", K(ret), K(my_plan_));
|
||||
} else if (!has_rollup()) {
|
||||
if (OB_FAIL(ObLogicalOperator::compute_equal_set())) {
|
||||
LOG_WARN("failed to compute equal set", K(ret));
|
||||
}
|
||||
} else if (filter_exprs_.empty()) {
|
||||
set_output_equal_sets(&empty_expr_sets_);
|
||||
} else if (OB_ISNULL(ordering_esets = get_plan()->create_equal_sets())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to create equal sets", K(ret));
|
||||
} else if (OB_FAIL(ObEqualAnalysis::compute_equal_set(
|
||||
&my_plan_->get_allocator(),
|
||||
filter_exprs_,
|
||||
*ordering_esets))) {
|
||||
LOG_WARN("failed to compute ordering output equal set", K(ret));
|
||||
} else {
|
||||
set_output_equal_sets(ordering_esets);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogGroupBy::compute_fd_item_set()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -148,6 +148,7 @@ public:
|
||||
|| ObRollupStatus::ROLLUP_DISTRIBUTOR == rollup_adaptive_info_.rollup_status_; }
|
||||
|
||||
virtual int compute_const_exprs() override;
|
||||
virtual int compute_equal_set() override;
|
||||
virtual int compute_fd_item_set() override;
|
||||
virtual int compute_op_ordering() override;
|
||||
double get_distinct_card() const { return distinct_card_; }
|
||||
|
||||
@ -925,7 +925,8 @@ int ObSelectStmt::get_equal_set_conditions(ObIArray<ObRawExpr *> &conditions,
|
||||
const bool check_having) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(ObDMLStmt::get_equal_set_conditions(conditions, is_strict, check_having))) {
|
||||
if (!(check_having && has_rollup()) &&
|
||||
OB_FAIL(ObDMLStmt::get_equal_set_conditions(conditions, is_strict, check_having))) {
|
||||
LOG_WARN("failed to get equal set cond", K(ret));
|
||||
} else if (!check_having) {
|
||||
// do nothing
|
||||
|
||||
@ -94,7 +94,8 @@ int ObTransformSimplifyDistinct::distinct_can_be_eliminated(ObSelectStmt *stmt,
|
||||
// Do nothing for non-select query.
|
||||
// When there are `@var := ` assignment, don't eliminate distinct.
|
||||
OPT_TRACE("stmt has assignment or calc found rows");
|
||||
} else if (stmt->has_distinct() && !stmt->is_set_stmt() && stmt->get_from_item_size() > 0) {
|
||||
} else if (stmt->has_distinct() && !stmt->is_set_stmt() && stmt->get_from_item_size() > 0 &&
|
||||
!stmt->has_rollup()) {
|
||||
// Only try to eliminate DISTINCT for plain SELECT
|
||||
int64_t limit_count = 0;
|
||||
const ObConstRawExpr *limit_expr = static_cast<ObConstRawExpr *>(stmt->get_limit_expr());
|
||||
|
||||
@ -202,7 +202,8 @@ int ObTransformSimplifyOrderby::remove_order_by_duplicates(ObDMLStmt *stmt,
|
||||
if (OB_ISNULL(stmt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("null pointer passed to transform", K(ret));
|
||||
} else if (!stmt->is_sel_del_upd()) {
|
||||
} else if (!stmt->is_sel_del_upd() ||
|
||||
(stmt->is_select_stmt() && (static_cast<ObSelectStmt*>(stmt)->has_rollup()))) {
|
||||
//do nothing
|
||||
} else {
|
||||
ObIArray<OrderItem> &order_items = stmt->get_order_items();
|
||||
|
||||
Reference in New Issue
Block a user