xiaokang commented on code in PR #34134:
URL: https://github.com/apache/doris/pull/34134#discussion_r1589866659
##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -982,15 +991,17 @@ std::string
SegmentIterator::_gen_predicate_result_sign(ColumnPredicate* predica
auto pred_type = predicate->type();
auto predicate_params = predicate->predicate_params();
pred_result_sign = BeConsts::BLOCK_TEMP_COLUMN_PREFIX +
column_desc->name() + "_" +
- predicate->pred_type_string(pred_type) + "_" +
predicate_params->value;
+ predicate->pred_type_string(pred_type) + "_";
+ pred_result_sign += join(predicate_params->values, ",");
Review Comment:
+= performance may be lower then +
##########
be/src/exec/olap_utils.h:
##########
@@ -117,6 +117,10 @@ inline SQLFilterOp to_olap_filter_type(const std::string&
function_name, bool op
return opposite ? FILTER_NOT_IN : FILTER_IN;
} else if (function_name == "ne") {
return opposite ? FILTER_IN : FILTER_NOT_IN;
+ } else if (function_name == "in_list") {
Review Comment:
Another to_olap_filter_type function should be changed as this.
##########
regression-test/suites/inverted_index_p0/test_compound_inlist.groovy:
##########
@@ -0,0 +1,140 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+suite("test_compound_inlist", "p0"){
+ def indexTbName1 = "test_compound_inlist_1"
+ def indexTbName2 = "test_compound_inlist_2"
+
+ sql "DROP TABLE IF EXISTS ${indexTbName1}"
+ sql """
+ CREATE TABLE ${indexTbName1} (
+ `@timestamp` int(11) NULL COMMENT "",
+ `clientip` varchar(20) NULL COMMENT "",
+ `request` text NULL COMMENT "",
+ `status` int(11) NULL COMMENT "",
+ `size` int(11) NULL COMMENT "",
+ INDEX clientip_idx (`clientip`) USING INVERTED PROPERTIES("parser" =
"english", "support_phrase" = "true") COMMENT '',
+ INDEX request_idx (`request`) USING INVERTED PROPERTIES("parser" =
"english", "support_phrase" = "true") COMMENT ''
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`@timestamp`)
+ COMMENT "OLAP"
+ DISTRIBUTED BY RANDOM BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "disable_auto_compaction" = "true"
+ );
+ """
+
+ sql "DROP TABLE IF EXISTS ${indexTbName2}"
+ sql """
+ CREATE TABLE ${indexTbName2} (
+ `@timestamp` int(11) NULL COMMENT "",
+ `clientip` varchar(20) NULL COMMENT "",
+ `request` text NULL COMMENT "",
+ `status` int(11) NULL COMMENT "",
+ `size` int(11) NULL COMMENT "",
+ INDEX clientip_idx (`clientip`) USING INVERTED PROPERTIES("parser" =
"english", "support_phrase" = "true") COMMENT '',
+ INDEX request_idx (`request`) USING INVERTED PROPERTIES("parser" =
"english", "support_phrase" = "true") COMMENT '',
+ INDEX status_idx (`status`) USING INVERTED COMMENT ''
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`@timestamp`)
+ COMMENT "OLAP"
+ DISTRIBUTED BY RANDOM BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "disable_auto_compaction" = "true"
+ );
+ """
+
+ def load_httplogs_data = {table_name, label, read_flag, format_flag,
file_name, ignore_failure=false,
+ expected_succ_rows = -1, load_to_single_tablet =
'true' ->
+
+ // load the json data
+ streamLoad {
+ table "${table_name}"
+
+ // set http request header params
+ set 'label', label + "_" + UUID.randomUUID().toString()
+ set 'read_json_by_line', read_flag
+ set 'format', format_flag
+ file file_name // import json file
+ time 10000 // limit inflight 10s
+ if (expected_succ_rows >= 0) {
+ set 'max_filter_ratio', '1'
+ }
+
+ // if declared a check callback, the default check condition will
ignore.
+ // So you must check all condition
+ check { result, exception, startTime, endTime ->
+ if (ignore_failure && expected_succ_rows < 0) { return }
+ if (exception != null) {
+ throw exception
+ }
+ log.info("Stream load result: ${result}".toString())
+ def json = parseJson(result)
+ assertEquals("success", json.Status.toLowerCase())
+ if (expected_succ_rows >= 0) {
+ assertEquals(json.NumberLoadedRows, expected_succ_rows)
+ } else {
+ assertEquals(json.NumberTotalRows,
json.NumberLoadedRows + json.NumberUnselectedRows)
+ assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes
> 0)
+ }
+ }
+ }
+ }
+
+ try {
+ load_httplogs_data.call(indexTbName1, 'test_compound_list_1', 'true',
'json', 'documents-1000.json')
+ load_httplogs_data.call(indexTbName2, 'test_compound_list_2', 'true',
'json', 'documents-1000.json')
+
+ sql "sync"
+
+ qt_sql """ select count() from ${indexTbName1} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status in (1, 2, 304)); """
+ qt_sql """ select count() from ${indexTbName2} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status in (1, 2, 304)); """
+
+ qt_sql """ select count() from ${indexTbName1} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status in (1, 2, 200)); """
+ qt_sql """ select count() from ${indexTbName2} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status in (1, 2, 200)); """
+
+ qt_sql """ select count() from ${indexTbName1} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status not in (1, 2, 304)); """
+ qt_sql """ select count() from ${indexTbName2} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status not in (1, 2, 304)); """
+
+ qt_sql """ select count() from ${indexTbName1} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status not in (1, 2, 200)); """
+ qt_sql """ select count() from ${indexTbName2} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) and status not in (1, 2, 200)); """
+
+ qt_sql """ select count() from ${indexTbName1} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) or status in (1, 2, 304)); """
+ qt_sql """ select count() from ${indexTbName2} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) or status in (1, 2, 304)); """
+
+ qt_sql """ select count() from ${indexTbName1} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) or status in (1, 2, 200)); """
+ qt_sql """ select count() from ${indexTbName2} where (((request
match_phrase 'images' and clientip match_phrase '3') or (request match_phrase
'english' and clientip match_phrase '4')) or status in (1, 2, 200)); """
+
+ qt_sql """ select count() from ${indexTbName1} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status in (1, 2, 304)); """
+ qt_sql """ select count() from ${indexTbName2} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status in (1, 2, 304)); """
+
+ qt_sql """ select count() from ${indexTbName1} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status in (1, 2, 200)); """
+ qt_sql """ select count() from ${indexTbName2} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status in (1, 2, 200)); """
+
+ qt_sql """ select count() from ${indexTbName1} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status not in (1, 2, 304)); """
+ qt_sql """ select count() from ${indexTbName2} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status not in (1, 2, 304)); """
+
+ qt_sql """ select count() from ${indexTbName1} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status in (1, 2, 304, 200) and status not in (1, 2,
304)); """
+ qt_sql """ select count() from ${indexTbName2} where ((request
match_phrase 'hm' and clientip match_phrase '1') or (request match_phrase 'jpg'
and clientip match_phrase '2')) or (((request match_phrase 'images' and
clientip match_phrase '3') or (request match_phrase 'english' and clientip
match_phrase '4')) and status in (1, 2, 304, 200) and status not in (1, 2,
304)); """
Review Comment:
you can add more complex query with both status and clientip in one sql.
##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -762,10 +762,17 @@ Status
SegmentIterator::_execute_predicates_except_leafnode_of_andnode(
_column_predicate_info->column_name = expr->expr_name();
} else if (_is_literal_node(node_type)) {
auto v_literal_expr =
std::dynamic_pointer_cast<doris::vectorized::VLiteral>(expr);
- _column_predicate_info->query_value = v_literal_expr->value();
- } else if (node_type == TExprNodeType::BINARY_PRED || node_type ==
TExprNodeType::MATCH_PRED) {
+
_column_predicate_info->query_values.push_back(v_literal_expr->value());
+ } else if (node_type == TExprNodeType::BINARY_PRED || node_type ==
TExprNodeType::MATCH_PRED ||
+ node_type == TExprNodeType::IN_PRED) {
if (node_type == TExprNodeType::MATCH_PRED) {
_column_predicate_info->query_op = "match";
+ } else if (node_type == TExprNodeType::IN_PRED) {
+ if (expr->op() == TExprOpcode::type::FILTER_IN) {
+ _column_predicate_info->query_op = "in_list";
Review Comment:
use a const var
##########
be/src/exec/olap_utils.h:
##########
@@ -117,6 +117,10 @@ inline SQLFilterOp to_olap_filter_type(const std::string&
function_name, bool op
return opposite ? FILTER_NOT_IN : FILTER_IN;
} else if (function_name == "ne") {
return opposite ? FILTER_IN : FILTER_NOT_IN;
+ } else if (function_name == "in_list") {
+ return opposite ? FILTER_IN : FILTER_NOT_IN;
Review Comment:
If opposite is true, it should return FILTER_NOT_IN.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]