add inner_same_as for udf func and remove useless GET_MIN_CLUSTER_VERSION

This commit is contained in:
Larry955
2022-11-16 07:35:39 +00:00
committed by wangzelin.wzl
parent 99d34dc07b
commit 8aee7d972f
34 changed files with 279 additions and 527 deletions

View File

@ -94,9 +94,6 @@ int ObExprGeneratorImpl::generate(ObRawExpr &raw_expr, ObSqlExpression &expr)
OB_LOG(WARN, "fail to get raw expr_count", K(ret));
} else if (OB_FAIL(expr.set_item_count(count))) {
OB_LOG(WARN, "fail to init item count", K(ret), K(count));
} else if (ObSqlExpressionUtil::should_gen_postfix_expr()
&& OB_FAIL(raw_expr.postorder_accept(*this))) {
LOG_WARN("failed to postorder accept", K(ret), K(raw_expr));
} else if (OB_FAIL(generate_infix_expr(raw_expr))) {
LOG_WARN("failed to generate infix expr", K(ret));
} else if (OB_FAIL(expr.generate_idx_for_regexp_ops(cur_regexp_op_count_))) {
@ -782,51 +779,48 @@ inline int ObExprGeneratorImpl::visit_in_expr(ObOpRawExpr &expr, ObExprInOrNotIn
}
//for row_type in left_param of EXPR IN
//if min_cluster_version < 3.1, do not check params can use hash optimizition
if (OB_SUCC(ret) && GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_3100) {
bool param_all_const = true;
bool param_all_same_type = true;
bool param_all_same_cs_type = true;
bool param_all_is_ext = true;
bool param_all_same_cs_level = true;
for (int64_t j = 0; OB_SUCC(ret) && j < in_op->get_row_dimension(); ++j) {
param_all_const &= param1->get_param_expr(0)->get_param_expr(j)
->is_static_const_expr();
ObObjType first_obj_type = param1->get_param_expr(0)->get_param_expr(j)
->get_data_type();
ObObjType cur_obj_type = ObMaxType;
ObCollationType first_obj_cs_type = param1->get_param_expr(0)->get_param_expr(j)
->get_collation_type();
ObCollationType cur_obj_cs_type = CS_TYPE_INVALID;
ObCollationLevel first_obj_cs_level = param1->get_param_expr(0)->get_param_expr(j)
->get_collation_level();
ObCollationLevel cur_obj_cs_level = CS_LEVEL_INVALID;
param_all_is_ext &= (ObExtendType == first_obj_type);
for (int64_t i = 1; OB_SUCC(ret) && i < param_count; ++i) {
cur_obj_type = param1->get_param_expr(i)->get_param_expr(j)->get_data_type();
cur_obj_cs_type = param1->get_param_expr(i)->get_param_expr(j)->get_collation_type();
cur_obj_cs_level = param1->get_param_expr(i)->get_param_expr(j)->get_collation_level();
if (ObNullType == first_obj_type) {
first_obj_type = cur_obj_type;
first_obj_cs_type = cur_obj_cs_type;
}
if (ObNullType != first_obj_type && ObNullType != cur_obj_type) {
param_all_const &= param1->get_param_expr(i)->get_param_expr(j)
->is_static_const_expr();
param_all_same_type &= (first_obj_type == cur_obj_type);
param_all_same_cs_type &= (first_obj_cs_type == cur_obj_cs_type);
param_all_same_cs_level &= (first_obj_cs_level == cur_obj_cs_level);
}
param_all_is_ext &= (ObExtendType == first_obj_type);
bool param_all_const = true;
bool param_all_same_type = true;
bool param_all_same_cs_type = true;
bool param_all_is_ext = true;
bool param_all_same_cs_level = true;
for (int64_t j = 0; OB_SUCC(ret) && j < in_op->get_row_dimension(); ++j) {
param_all_const &= param1->get_param_expr(0)->get_param_expr(j)
->is_static_const_expr();
ObObjType first_obj_type = param1->get_param_expr(0)->get_param_expr(j)
->get_data_type();
ObObjType cur_obj_type = ObMaxType;
ObCollationType first_obj_cs_type = param1->get_param_expr(0)->get_param_expr(j)
->get_collation_type();
ObCollationType cur_obj_cs_type = CS_TYPE_INVALID;
ObCollationLevel first_obj_cs_level = param1->get_param_expr(0)->get_param_expr(j)
->get_collation_level();
ObCollationLevel cur_obj_cs_level = CS_LEVEL_INVALID;
param_all_is_ext &= (ObExtendType == first_obj_type);
for (int64_t i = 1; OB_SUCC(ret) && i < param_count; ++i) {
cur_obj_type = param1->get_param_expr(i)->get_param_expr(j)->get_data_type();
cur_obj_cs_type = param1->get_param_expr(i)->get_param_expr(j)->get_collation_type();
cur_obj_cs_level = param1->get_param_expr(i)->get_param_expr(j)->get_collation_level();
if (ObNullType == first_obj_type) {
first_obj_type = cur_obj_type;
first_obj_cs_type = cur_obj_cs_type;
}
if (ObNullType != first_obj_type && ObNullType != cur_obj_type) {
param_all_const &= param1->get_param_expr(i)->get_param_expr(j)
->is_static_const_expr();
param_all_same_type &= (first_obj_type == cur_obj_type);
param_all_same_cs_type &= (first_obj_cs_type == cur_obj_cs_type);
param_all_same_cs_level &= (first_obj_cs_level == cur_obj_cs_level);
}
param_all_is_ext &= (ObExtendType == first_obj_type);
}
in_op->set_param_all_const(param_all_const);
in_op->set_param_all_same_type(param_all_same_type);
in_op->set_param_all_same_cs_type(lib::is_oracle_mode()
? param_all_same_cs_type
: (param_all_same_cs_type &= param_all_same_cs_level));
in_op->set_param_is_ext_type_oracle(param_all_is_ext);
}
in_op->set_param_all_const(param_all_const);
in_op->set_param_all_same_type(param_all_same_type);
in_op->set_param_all_same_cs_type(lib::is_oracle_mode()
? param_all_same_cs_type
: (param_all_same_cs_type &= param_all_same_cs_level));
in_op->set_param_is_ext_type_oracle(param_all_is_ext);
}
} else {
// like a in (1, 2, 3)
@ -1487,32 +1481,6 @@ int ObExprGeneratorImpl::visit(ObOpRawExpr &expr)
} else {
ObExprOperator *op = NULL;
ObExprOperatorType type = expr.get_expr_type();
if (GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_3100) {
switch (expr.get_expr_type()) {
case T_OP_AGG_ADD: {
type = T_OP_ADD;
break;
}
case T_OP_AGG_MINUS: {
type = T_OP_MINUS;
break;
}
case T_OP_AGG_MUL: {
type = T_OP_MUL;
break;
}
case T_OP_AGG_DIV: {
type = T_OP_DIV;
break;
}
default: {
}
};
if (type != expr.get_expr_type()) {
LOG_DEBUG("replace agg arithmetic op to arithmetic op for compatibility",
K(type), K(expr.get_expr_type()));
}
}
if (OB_FAIL(factory_.alloc(type, op))) {
LOG_WARN("fail to alloc expr_op", K(ret));
} else if (OB_UNLIKELY(NULL == op)) {

View File

@ -2408,17 +2408,11 @@ int ObStaticEngineCG::generate_spec(ObLogJoinFilter &op, ObJoinFilterSpec &spec,
LOG_WARN("failed to push back hash func", K(ret));
}
} else {
bool is_new_hash_version = (GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_0_0_0);
for (int64_t i = 0; i < spec.join_keys_.count() && OB_SUCC(ret); ++i) {
ObExpr *join_expr = spec.join_keys_.at(i);
ObHashFunc hash_func;
if (is_new_hash_version) {
hash_func.hash_func_ = join_expr->basic_funcs_->murmur_hash_;
hash_func.batch_hash_func_ = join_expr->basic_funcs_->murmur_hash_batch_;
} else {
hash_func.hash_func_ = join_expr->basic_funcs_->default_hash_;
hash_func.batch_hash_func_ = join_expr->basic_funcs_->default_hash_batch_;
}
hash_func.hash_func_ = join_expr->basic_funcs_->murmur_hash_;
hash_func.batch_hash_func_ = join_expr->basic_funcs_->murmur_hash_batch_;
if (OB_ISNULL(hash_func.hash_func_) || OB_ISNULL(hash_func.batch_hash_func_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("hash func is null, check datatype is valid", K(ret));
@ -2612,14 +2606,13 @@ int ObStaticEngineCG::generate_basic_receive_spec(ObLogExchange &op, ObPxReceive
LOG_WARN("batch op type is unexpected", K(ret), K(op.get_px_batch_op_type()));
}
}
if (OB_SUCC(ret) && GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_2276) {
if (OB_FAIL(coord->get_table_locations().prepare_allocate(op.get_pruning_table_locations().count(),
phy_plan_->get_allocator()))) {
LOG_WARN("fail to init pruning table locations", K(ret));
} else {
for (int i = 0; i < op.get_pruning_table_locations().count() && OB_SUCC(ret); ++i) {
OZ(coord->get_table_locations().at(i).assign(op.get_pruning_table_locations().at(i)));
}
if (OB_FAIL(ret)) {
} else if (OB_FAIL(coord->get_table_locations().prepare_allocate(op.get_pruning_table_locations().count(),
phy_plan_->get_allocator()))) {
LOG_WARN("fail to init pruning table locations", K(ret));
} else {
for (int i = 0; i < op.get_pruning_table_locations().count() && OB_SUCC(ret); ++i) {
OZ(coord->get_table_locations().at(i).assign(op.get_pruning_table_locations().at(i)));
}
}
LOG_TRACE("map worker to px coordinator", K(spec.get_type()),
@ -6287,11 +6280,9 @@ int ObStaticEngineCG::get_phy_op_type(ObLogicalOperator &log_op,
case NESTED_LOOP_JOIN: {
type = CONNECT_BY_JOIN != op.get_join_type()
? PHY_NESTED_LOOP_JOIN
: (GET_MIN_CLUSTER_VERSION() <= CLUSTER_VERSION_2250
? PHY_NESTED_LOOP_CONNECT_BY_WITH_INDEX
: (op.get_nl_params().count() > 0
: (op.get_nl_params().count() > 0
? PHY_NESTED_LOOP_CONNECT_BY_WITH_INDEX
: PHY_NESTED_LOOP_CONNECT_BY));
: PHY_NESTED_LOOP_CONNECT_BY);
break;
}
case MERGE_JOIN: {