@@ -1566,7 +1566,7 @@ int ObESQueryParser::parse_range(ObIJsonBase &req_node, ObEsQueryInfo &query_inf
15661566 int ret = OB_SUCCESS ;
15671567 ObString col_name;
15681568 ObIJsonBase *sub_node = nullptr ;
1569- ObReqColumnExpr *col_para = nullptr ;
1569+ ObReqExpr *key_expr = nullptr ;
15701570 uint64_t count = 0 ;
15711571 int condition_num = 0 ;
15721572 common::ObSEArray<ObReqExpr *, 4 , common::ModulePageAllocator, true > condition_exprs;
@@ -1585,8 +1585,8 @@ int ObESQueryParser::parse_range(ObIJsonBase &req_node, ObEsQueryInfo &query_inf
15851585 } else if (count == 0 ) {
15861586 ret = OB_INVALID_ARGUMENT ;
15871587 LOG_WARN (" unexpectd range condition" , K (ret));
1588- } else if (OB_FAIL (ObReqColumnExpr::construct_column_expr (col_para, alloc_, col_name ))) {
1589- LOG_WARN (" fail to create column expr" , K (ret));
1588+ } else if (OB_FAIL (create_column_or_base_expr (col_name, key_expr ))) {
1589+ LOG_WARN (" fail to create column or base expr" , K (ret));
15901590 }
15911591 for (uint64_t i = 0 ; OB_SUCC (ret) && i < count; i++) {
15921592 ObString key;
@@ -1627,7 +1627,7 @@ int ObESQueryParser::parse_range(ObIJsonBase &req_node, ObEsQueryInfo &query_inf
16271627 }
16281628
16291629 if (OB_FAIL (ret)) {
1630- } else if (type != T_INVALID && OB_FAIL (ObReqOpExpr::construct_binary_op_expr (cmp_expr, alloc_, type, col_para , var))) {
1630+ } else if (type != T_INVALID && OB_FAIL (ObReqOpExpr::construct_binary_op_expr (cmp_expr, alloc_, type, key_expr , var))) {
16311631 LOG_WARN (" fail to construct cmp expr" , K (ret));
16321632 } else if (OB_FAIL (condition_exprs.push_back (cmp_expr))) {
16331633 LOG_WARN (" fail to add condition to array" , K (ret));
@@ -2005,7 +2005,7 @@ int ObESQueryParser::parse_term(ObIJsonBase &req_node, ObEsQueryInfo &query_info
20052005 ObString col_name;
20062006 ObIJsonBase *col_para = NULL ;
20072007 ObReqOpExpr *eq_expr = NULL ;
2008- ObReqColumnExpr *col_expr = NULL ;
2008+ ObReqExpr *key_expr = NULL ;
20092009 ObReqConstExpr *value_expr = NULL ;
20102010 query_info.query_item_ = QUERY_ITEM_TERM ;
20112011 if (req_node.json_type () != ObJsonNodeType::J_OBJECT ) {
@@ -2016,15 +2016,15 @@ int ObESQueryParser::parse_term(ObIJsonBase &req_node, ObEsQueryInfo &query_info
20162016 LOG_WARN (" term expr should have exactly one element" , K (ret));
20172017 } else if (OB_FAIL (req_node.get_object_value (0 , col_name, col_para))) {
20182018 LOG_WARN (" fail to get value." , K (ret));
2019- } else if (OB_FAIL (ObReqColumnExpr::construct_column_expr (col_expr, alloc_, col_name ))) {
2020- LOG_WARN (" fail to create term expr" , K (ret));
2019+ } else if (OB_FAIL (create_column_or_base_expr (col_name, key_expr ))) {
2020+ LOG_WARN (" fail to create column or base expr" , K (ret));
20212021 } else if (col_para->json_type () == ObJsonNodeType::J_ARRAY ) {
20222022 ret = OB_ERR_INVALID_TYPE_FOR_ARGUMENT ;
20232023 LOG_WARN (" term field should have exactly one element" , K (ret));
20242024 } else if (col_para->json_type () != ObJsonNodeType::J_OBJECT ) {
20252025 if (OB_FAIL (parse_const (*col_para, value_expr))) {
20262026 LOG_WARN (" fail to parse const value" , K (ret));
2027- } else if (OB_FAIL (ObReqOpExpr::construct_binary_op_expr (eq_expr, alloc_, T_OP_EQ , col_expr , value_expr))) {
2027+ } else if (OB_FAIL (ObReqOpExpr::construct_binary_op_expr (eq_expr, alloc_, T_OP_EQ , key_expr , value_expr))) {
20282028 LOG_WARN (" fail to construct eq expr" , K (ret));
20292029 } else {
20302030 query_info.score_expr_ = eq_expr;
@@ -2039,7 +2039,7 @@ int ObESQueryParser::parse_term(ObIJsonBase &req_node, ObEsQueryInfo &query_info
20392039 } else if (key.case_compare (" value" ) == 0 ) {
20402040 if (OB_FAIL (parse_const (*value_node, value_expr))) {
20412041 LOG_WARN (" fail to parse const value" , K (ret));
2042- } else if (OB_FAIL (ObReqOpExpr::construct_binary_op_expr (eq_expr, alloc_, T_OP_EQ , col_expr , value_expr))) {
2042+ } else if (OB_FAIL (ObReqOpExpr::construct_binary_op_expr (eq_expr, alloc_, T_OP_EQ , key_expr , value_expr))) {
20432043 LOG_WARN (" fail to construct eq expr" , K (ret));
20442044 }
20452045 } else if (key.case_compare (" boost" ) == 0 ) {
@@ -2070,7 +2070,7 @@ int ObESQueryParser::parse_terms(ObIJsonBase &req_node, ObEsQueryInfo &query_inf
20702070{
20712071 int ret = OB_SUCCESS ;
20722072 uint64_t count = 0 ;
2073- ObReqColumnExpr *col_expr = NULL ;
2073+ ObReqExpr *key_expr = NULL ;
20742074 ObReqConstExpr *value_expr = NULL ;
20752075 ObReqOpExpr *in_expr = NULL ;
20762076 common::ObSEArray<ObReqConstExpr*, 4 , common::ModulePageAllocator, true > value_exprs;
@@ -2108,11 +2108,11 @@ int ObESQueryParser::parse_terms(ObIJsonBase &req_node, ObEsQueryInfo &query_inf
21082108 ret = OB_INVALID_ARGUMENT ;
21092109 LOG_WARN (" field should not be empty string" , K (ret));
21102110 } else if (FALSE_IT (has_field = true )) {
2111- } else if (OB_FAIL (ObReqColumnExpr::construct_column_expr (col_expr, alloc_, key ))) {
2112- LOG_WARN (" fail to create term expr" , K (ret));
2111+ } else if (OB_FAIL (create_column_or_base_expr (key, key_expr ))) {
2112+ LOG_WARN (" fail to create column or base expr" , K (ret));
21132113 } else if (OB_FAIL (parse_keyword_array (*value_node, value_exprs))) {
21142114 LOG_WARN (" fail to parse keyword array" , K (ret));
2115- } else if (OB_FAIL (ObReqOpExpr::construct_in_expr (alloc_, col_expr , value_exprs, in_expr))) {
2115+ } else if (OB_FAIL (ObReqOpExpr::construct_in_expr (alloc_, key_expr , value_exprs, in_expr))) {
21162116 LOG_WARN (" fail to construct in expr" , K (ret));
21172117 }
21182118 }
@@ -3979,6 +3979,36 @@ int ObESQueryParser::construct_partition_cols(const ObIArray<ObString> &column_n
39793979 return ret;
39803980}
39813981
3982+ bool ObESQueryParser::check_is_column_name (const ObString &key)
3983+ {
3984+ bool is_column_name = false ;
3985+ for (int64_t i = 0 ; !is_column_name && i < user_cols_.count (); i++) {
3986+ if (user_cols_.at (i).case_compare (key) == 0 ) {
3987+ is_column_name = true ;
3988+ }
3989+ }
3990+ LOG_INFO (" hnwyllmm check_is_column_name" , K (key), K (is_column_name));
3991+ return is_column_name;
3992+ }
3993+
3994+ int ObESQueryParser::create_column_or_base_expr (const ObString &key, ObReqExpr *&expr)
3995+ {
3996+ int ret = OB_SUCCESS ;
3997+ if (check_is_column_name (key)) {
3998+ ObReqColumnExpr *col_expr = nullptr ;
3999+ if (OB_FAIL (ObReqColumnExpr::construct_column_expr (col_expr, alloc_, key))) {
4000+ LOG_WARN (" fail to create column expr" , K (ret));
4001+ } else {
4002+ expr = col_expr;
4003+ }
4004+ } else {
4005+ if (OB_FAIL (ObReqExpr::construct_expr (expr, alloc_, key))) {
4006+ LOG_WARN (" fail to create normal expr" , K (ret));
4007+ }
4008+ }
4009+ return ret;
4010+ }
4011+
39824012void ObEsQueryInfo::set_msm_apply_type ()
39834013{
39844014 uint64_t msm_val = msm_info_.get_msm_val ();
0 commit comments