Fix bit agg function add redundant cast
This commit is contained in:
		
							
								
								
									
										3
									
								
								deps/oblib/src/common/object/ob_obj_type.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								deps/oblib/src/common/object/ob_obj_type.h
									
									
									
									
										vendored
									
									
								
							| @ -1395,7 +1395,8 @@ inline bool ob_is_unsigned_type(ObObjType type) | |||||||
|           || ObYearType == type |           || ObYearType == type | ||||||
|           || ObUFloatType == type |           || ObUFloatType == type | ||||||
|           || ObUDoubleType == type |           || ObUDoubleType == type | ||||||
|           || ObUNumberType == type; |           || ObUNumberType == type | ||||||
|  |           || ObBitType == type; | ||||||
| } | } | ||||||
| bool is_match_alter_integer_column_online_ddl_rules(const common::ObObjMeta& src_meta, | bool is_match_alter_integer_column_online_ddl_rules(const common::ObObjMeta& src_meta, | ||||||
|                                                     const common::ObObjMeta& dst_meta); |                                                     const common::ObObjMeta& dst_meta); | ||||||
|  | |||||||
| @ -1423,6 +1423,7 @@ int ObRawExprDeduceType::visit(ObAggFunRawExpr &expr) | |||||||
|     LOG_WARN("failed to check group aggr param", K(ret)); |     LOG_WARN("failed to check group aggr param", K(ret)); | ||||||
|   } else { |   } else { | ||||||
|     bool need_add_cast = false; |     bool need_add_cast = false; | ||||||
|  |     bool override_calc_meta = true; | ||||||
|     switch (expr.get_expr_type()) { |     switch (expr.get_expr_type()) { | ||||||
|       //count_sum是在分布式的count(*)中上层为了避免select a, count(a) from t1这种语句a出现NULL这种非期望值 |       //count_sum是在分布式的count(*)中上层为了避免select a, count(a) from t1这种语句a出现NULL这种非期望值 | ||||||
|       //而生成的内部表达式 |       //而生成的内部表达式 | ||||||
| @ -1497,11 +1498,13 @@ int ObRawExprDeduceType::visit(ObAggFunRawExpr &expr) | |||||||
|           LOG_WARN("param expr is null", K(expr)); |           LOG_WARN("param expr is null", K(expr)); | ||||||
|         } else { |         } else { | ||||||
|           result_type.set_type(ObUInt64Type); |           result_type.set_type(ObUInt64Type); | ||||||
|           result_type.set_calc_type(result_type.get_type()); |           result_type.set_calc_type(ob_is_unsigned_type(child_expr->get_data_type()) ? | ||||||
|  |             ObUInt64Type : ObIntType); | ||||||
|  |           override_calc_meta = false; | ||||||
|           result_type.set_accuracy(ObAccuracy::MAX_ACCURACY2[0/*is_oracle*/][ObUInt64Type]); |           result_type.set_accuracy(ObAccuracy::MAX_ACCURACY2[0/*is_oracle*/][ObUInt64Type]); | ||||||
|           expr.set_result_type(result_type); |           expr.set_result_type(result_type); | ||||||
|           ObObjTypeClass from_tc = child_expr->get_type_class(); |           ObObjTypeClass from_tc = child_expr->get_type_class(); | ||||||
|           need_add_cast = (ObUIntTC != from_tc && ObIntTC != from_tc); |           need_add_cast = (ObUIntTC != from_tc && ObIntTC != from_tc && ObBitTC != from_tc); | ||||||
|         } |         } | ||||||
|         break; |         break; | ||||||
|       } |       } | ||||||
| @ -1927,8 +1930,11 @@ int ObRawExprDeduceType::visit(ObAggFunRawExpr &expr) | |||||||
|     } |     } | ||||||
|     LOG_DEBUG("aggregate function deduced result type", K(result_type), K(need_add_cast), K(expr)); |     LOG_DEBUG("aggregate function deduced result type", K(result_type), K(need_add_cast), K(expr)); | ||||||
|     if (OB_SUCC(ret) && need_add_cast) { |     if (OB_SUCC(ret) && need_add_cast) { | ||||||
|  |       if (override_calc_meta) { | ||||||
|         result_type.set_calc_type(result_type.get_type()); |         result_type.set_calc_type(result_type.get_type()); | ||||||
|         result_type.set_calc_accuracy(result_type.get_accuracy()); |         result_type.set_calc_accuracy(result_type.get_accuracy()); | ||||||
|  |         result_type.set_calc_meta(result_type.get_obj_meta()); | ||||||
|  |       } | ||||||
|       if (T_FUN_AVG == expr.get_expr_type() && -2 != scale_increment_recover) { |       if (T_FUN_AVG == expr.get_expr_type() && -2 != scale_increment_recover) { | ||||||
|         result_type.set_calc_scale(scale_increment_recover); |         result_type.set_calc_scale(scale_increment_recover); | ||||||
|       } |       } | ||||||
| @ -3500,7 +3506,6 @@ int ObRawExprDeduceType::add_implicit_cast(ObAggFunRawExpr &parent, | |||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|   ObExprResType res_type = parent.get_result_type(); |   ObExprResType res_type = parent.get_result_type(); | ||||||
|   res_type.set_calc_meta(res_type.get_obj_meta()); |  | ||||||
|   ObIArray<ObRawExpr*> &real_param_exprs = parent.get_real_param_exprs_for_update(); |   ObIArray<ObRawExpr*> &real_param_exprs = parent.get_real_param_exprs_for_update(); | ||||||
|   for (int64_t i = 0; OB_SUCC(ret) && i < real_param_exprs.count(); ++i) { |   for (int64_t i = 0; OB_SUCC(ret) && i < real_param_exprs.count(); ++i) { | ||||||
|     ObRawExpr *&child_ptr = real_param_exprs.at(i); |     ObRawExpr *&child_ptr = real_param_exprs.at(i); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 hezuojiao
					hezuojiao