[FEAT MERGE]4_1_sql_feature

Co-authored-by: leslieyuchen <leslieyuchen@gmail.com>
Co-authored-by: Charles0429 <xiezhenjiang@gmail.com>
Co-authored-by: raywill <hustos@gmail.com>
This commit is contained in:
obdev
2023-01-28 16:01:26 +08:00
committed by ob-robot
parent 3080f2b66f
commit 2d19a9d8f5
846 changed files with 161957 additions and 116661 deletions

View File

@ -38,28 +38,27 @@ const char *ObLogDistinct::get_name() const
return MERGE_AGGREGATE == algo_ ? "MERGE DISTINCT" : "HASH DISTINCT";
}
int ObLogDistinct::print_my_plan_annotation(char *buf,
int64_t &buf_len,
int64_t &pos,
ExplainType type)
int ObLogDistinct::get_plan_item_info(PlanText &plan_text,
ObSqlPlanItem &plan_item)
{
int ret = OB_SUCCESS;
// print access
if (OB_FAIL(BUF_PRINTF(", "))) {
LOG_WARN("BUF_PRINTF fails",K(ret));
} else if (OB_FAIL(BUF_PRINTF("\n "))) {
LOG_WARN("BUF_PRINTF fails",K(ret));
} else { /* Do nothing */ }
const ObIArray<ObRawExpr*> &distinct = distinct_exprs_;
EXPLAIN_PRINT_EXPRS(distinct, type);
if (OB_SUCC(ret) && is_block_mode_) {
ret = BUF_PRINTF(", block");
if (OB_FAIL(ObLogicalOperator::get_plan_item_info(plan_text, plan_item))) {
LOG_WARN("failed to get base plan item info", K(ret));
} else {
BEGIN_BUF_PRINT;
EXPLAIN_PRINT_EXPRS(distinct, type);
if (OB_SUCC(ret) && is_block_mode_) {
ret = BUF_PRINTF(", block");
}
END_BUF_PRINT(plan_item.special_predicates_,
plan_item.special_predicates_len_);
}
return ret;
}
int ObLogDistinct::inner_replace_generated_agg_expr(
int ObLogDistinct::inner_replace_op_exprs(
const ObIArray<std::pair<ObRawExpr *, ObRawExpr*> >&to_replace_exprs)
{
int ret = OB_SUCCESS;
@ -257,7 +256,6 @@ int ObLogDistinct::compute_fd_item_set()
} else if (OB_FAIL(my_plan_->get_fd_item_factory().create_table_fd_item(fd_item,
true,
distinct_exprs_,
get_stmt()->get_current_level(),
get_table_set()))) {
LOG_WARN("failed to create fd item", K(ret));
} else if (OB_FAIL(fd_item_set->push_back(fd_item))) {
@ -307,23 +305,50 @@ int ObLogDistinct::generate_link_sql_post(GenLinkStmtPostContext &link_ctx)
return ret;
}
int ObLogDistinct::print_outline(planText &plan_text)
int ObLogDistinct::print_outline_data(PlanText &plan_text)
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
const ObDMLStmt *stmt = NULL;
ObString qb_name;
const ObLogicalOperator *child = NULL;
const ObLogicalOperator *op = NULL;
if (is_push_down()) {
/* print outline in top distinct */
} else if (OB_ISNULL(get_plan()) || OB_ISNULL(stmt = get_plan()->get_stmt())
|| OB_ISNULL(child = get_child(ObLogicalOperator::first_child))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected NULL", K(ret), K(get_plan()), K(stmt), K(child));
} else if (OB_FAIL(child->get_pushdown_op(log_op_def::LOG_DISTINCT, op))) {
LOG_WARN("failed to get push down distinct", K(ret));
} else if (OB_FAIL(stmt->get_qb_name(qb_name))) {
LOG_WARN("fail to get qb_name", K(ret), K(stmt->get_stmt_id()));
} else if (NULL != op &&
OB_FAIL(BUF_PRINTF("%s%s(@\"%.*s\")",
ObQueryHint::get_outline_indent(plan_text.is_oneline_),
ObHint::get_hint_name(T_DISTINCT_PUSHDOWN),
qb_name.length(),
qb_name.ptr()))) {
LOG_WARN("fail to print buffer", K(ret), K(buf), K(buf_len), K(pos));
} else if (HASH_AGGREGATE == algo_ &&
OB_FAIL(BUF_PRINTF("%s%s(@\"%.*s\")",
ObQueryHint::get_outline_indent(plan_text.is_oneline_),
ObHint::get_hint_name(T_USE_HASH_DISTINCT),
qb_name.length(),
qb_name.ptr()))) {
LOG_WARN("fail to print buffer", K(ret), K(buf), K(buf_len), K(pos));
} else {/*do nothing*/}
return ret;
}
int ObLogDistinct::print_used_hint(PlanText &plan_text)
{
int ret = OB_SUCCESS;
if (is_push_down()) {
/* print outline in top distinct */
} else if (USED_HINT == plan_text.outline_type_ && OB_FAIL(print_used_hint(plan_text))) {
LOG_WARN("fail to print used hint", K(ret));
} else if (OUTLINE_DATA == plan_text.outline_type_ && OB_FAIL(print_outline_data(plan_text))) {
LOG_WARN("fail to print outline data", K(ret));
}
return ret;
}
int ObLogDistinct::print_used_hint(planText &plan_text)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(get_plan())) {
} else if (OB_ISNULL(get_plan())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected NULL", K(ret), K(get_plan()));
} else {
@ -356,39 +381,5 @@ int ObLogDistinct::print_used_hint(planText &plan_text)
return ret;
}
int ObLogDistinct::print_outline_data(planText &plan_text)
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
const ObDMLStmt *stmt = NULL;
ObString qb_name;
const ObLogicalOperator *child = NULL;
const ObLogicalOperator *op = NULL;
if (OB_ISNULL(get_plan()) || OB_ISNULL(stmt = get_plan()->get_stmt())
|| OB_ISNULL(child = get_child(ObLogicalOperator::first_child))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected NULL", K(ret), K(get_plan()), K(stmt), K(child));
} else if (OB_FAIL(child->get_pushdown_op(log_op_def::LOG_DISTINCT, op))) {
LOG_WARN("failed to get push down distinct", K(ret));
} else if (OB_FAIL(stmt->get_qb_name(qb_name))) {
LOG_WARN("fail to get qb_name", K(ret), K(stmt->get_stmt_id()));
} else if (NULL != op &&
OB_FAIL(BUF_PRINTF("%s%s(@\"%.*s\")",
ObQueryHint::get_outline_indent(plan_text.is_oneline_),
ObHint::get_hint_name(T_DISTINCT_PUSHDOWN),
qb_name.length(), qb_name.ptr()))) {
LOG_WARN("fail to print buffer", K(ret), K(buf), K(buf_len), K(pos));
} else if (HASH_AGGREGATE == algo_ &&
OB_FAIL(BUF_PRINTF("%s%s(@\"%.*s\")",
ObQueryHint::get_outline_indent(plan_text.is_oneline_),
ObHint::get_hint_name(T_USE_HASH_DISTINCT),
qb_name.length(), qb_name.ptr()))) {
LOG_WARN("fail to print buffer", K(ret), K(buf), K(buf_len), K(pos));
} else {/*do nothing*/}
return ret;
}
}
}