fix some small bugs
This commit is contained in:
parent
f335d5a1ce
commit
de99c9e067
@ -349,7 +349,7 @@ int ObExprIsNot::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObEx
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("second param of is expr is not null, true or false", K(ret), K(param2->get_value()));
|
||||
LOG_WARN("second param of is expr is not null, true, false or infinite or nan", K(ret), K(param2->get_value()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -4507,23 +4507,30 @@ int ObSelectResolver::resolve_column_ref_in_group_by(const ObQualifiedName& q_na
|
||||
LOG_WARN("select stmt is null");
|
||||
} else if (!is_oracle_mode() && q_name.parent_aggr_level_ < current_level_) {
|
||||
// the column don't located in aggregate function in having clause
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < select_stmt->get_group_expr_size(); ++i) {
|
||||
// resolve column refs from group by and rollup exprs
|
||||
ObSEArray<ObRawExpr *, 16> group_and_rollup_exprs;
|
||||
if (OB_FAIL(append(group_and_rollup_exprs, select_stmt->get_group_exprs()))) {
|
||||
LOG_WARN("failed to append group exprs", K(ret));
|
||||
} else if (OB_FAIL(append(group_and_rollup_exprs, select_stmt->get_rollup_exprs()))) {
|
||||
LOG_WARN("failed to append rollup exprs", K(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < group_and_rollup_exprs.count(); ++i) {
|
||||
bool is_hit = false;
|
||||
ObRawExpr* group_expr = NULL;
|
||||
ObColumnRefRawExpr* col_ref = NULL;
|
||||
if (OB_ISNULL(group_expr = select_stmt->get_group_exprs().at(i))) {
|
||||
ObRawExpr *expr = NULL;
|
||||
ObColumnRefRawExpr *col_ref = NULL;
|
||||
if (OB_ISNULL(expr = group_and_rollup_exprs.at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("group expr is null");
|
||||
} else if (group_expr->is_column_ref_expr()) {
|
||||
col_ref = static_cast<ObColumnRefRawExpr*>(group_expr);
|
||||
if (OB_FAIL(ObResolverUtils::check_column_name(session_info_, q_name, *col_ref, is_hit))) {
|
||||
LOG_WARN("check column name failed", K(ret), K(q_name));
|
||||
} else if (is_hit) {
|
||||
if (NULL == real_ref_expr) {
|
||||
real_ref_expr = col_ref;
|
||||
} else if (real_ref_expr != col_ref) {
|
||||
ret = OB_NON_UNIQ_ERROR;
|
||||
}
|
||||
LOG_WARN("expr is null", K(ret));
|
||||
} else if (!expr->is_column_ref_expr()) {
|
||||
// do nothing
|
||||
} else if (OB_FALSE_IT(col_ref = static_cast<ObColumnRefRawExpr *>(expr))) {
|
||||
} else if (OB_FAIL(ObResolverUtils::check_column_name(session_info_, q_name, *col_ref, is_hit))) {
|
||||
LOG_WARN("check column name failed", K(ret), K(q_name));
|
||||
} else if (is_hit) {
|
||||
if (OB_ISNULL(real_ref_expr)) {
|
||||
real_ref_expr = col_ref;
|
||||
} else if (real_ref_expr != col_ref) {
|
||||
ret = OB_NON_UNIQ_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1015,10 +1015,36 @@ int ObTransformGroupByPlacement::push_down_group_by_into_view(ObSelectStmt* stmt
|
||||
if (OB_ISNULL(expr) || OB_UNLIKELY(!expr->is_aggr_expr())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("aggr expr is null", K(ret));
|
||||
} else if (OB_FAIL(sub_stmt->add_agg_item(static_cast<ObAggFunRawExpr&>(*expr)))) {
|
||||
LOG_WARN("failed to add aggr item", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::create_select_item(*ctx_->allocator_, expr, sub_stmt))) {
|
||||
LOG_WARN("failed to add select item", K(ret));
|
||||
} else {
|
||||
ObSEArray<ObRawExpr *, 8> old_params;
|
||||
ObSEArray<ObRawExpr *, 8> new_params;
|
||||
ObRawExpr *old_param = NULL;
|
||||
ObRawExpr *new_param = NULL;
|
||||
for (uint8_t i = 0; OB_SUCC(ret) && i < expr->get_param_count(); ++i) {
|
||||
if (OB_ISNULL(old_param = expr->get_param_expr(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("expr param should not be null", K(ret), K(*expr));
|
||||
} else if (OB_FAIL(ObRawExprUtils::copy_expr(*ctx_->expr_factory_, old_param, new_param, COPY_REF_DEFAULT))) {
|
||||
LOG_WARN("failed to copy expr", K(ret), K(*old_param), K(*new_param));
|
||||
} else if (OB_ISNULL(new_param)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null expr", K(ret), K(*old_param), K(*new_param));
|
||||
} else if (OB_FAIL(old_params.push_back(old_param))) {
|
||||
LOG_WARN("failed to push pack old param", K(ret), K(*old_param));
|
||||
} else if (OB_FAIL(new_params.push_back(new_param))) {
|
||||
LOG_WARN("failed to push back new param", K(ret), K(*new_param));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(ObTransformUtils::replace_expr(old_params, new_params, expr))) {
|
||||
LOG_WARN("failed to replace params", K(ret), K(old_params), K(new_params));
|
||||
} else if (OB_FAIL(sub_stmt->add_agg_item(static_cast<ObAggFunRawExpr &>(*expr)))) {
|
||||
LOG_WARN("failed to add aggr item", K(ret));
|
||||
} else if (OB_FAIL(expr->formalize(ctx_->session_info_))) {
|
||||
LOG_WARN("failed to formalize expr", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::create_select_item(*ctx_->allocator_, expr, sub_stmt))) {
|
||||
LOG_WARN("failed to add select item", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -7590,7 +7590,15 @@ int ObTransformUtils::replace_with_groupby_exprs(ObSelectStmt* select_stmt, ObRa
|
||||
} else if (OB_FAIL(check_context.init(select_stmt->get_query_ctx()))) {
|
||||
LOG_WARN("failed to init check context.", K(ret));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < expr->get_param_count(); i++) {
|
||||
int64_t param_cnt = expr->get_param_count();
|
||||
// only first param should be replaced (if needed) for T_OP_IS and T_OP_IS_NOT expr
|
||||
// select null as aa group by aa having null is null;
|
||||
// the first null in having exprs is allowed to be parameterized
|
||||
// but the second null is not allowed
|
||||
if (T_OP_IS == expr->get_expr_type() || T_OP_IS_NOT == expr->get_expr_type()) {
|
||||
param_cnt = 1;
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < param_cnt; i++) {
|
||||
if (OB_FAIL(SMART_CALL(replace_with_groupby_exprs(select_stmt, expr->get_param_expr(i))))) {
|
||||
LOG_WARN("failed to replace with groupby columns.", K(ret));
|
||||
} else { /*do nothing.*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user