This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e51af0784 [fix](scan) Avoid using incorrect cache code in 
ComparisonPredicate (#18332)
1e51af0784 is described below

commit 1e51af078450c03e8954b14daa0cdc73bbf0a934
Author: Jerry Hu <[email protected]>
AuthorDate: Mon Apr 3 20:37:35 2023 +0800

    [fix](scan) Avoid using incorrect cache code in ComparisonPredicate (#18332)
    
    * [fix](scan) Avoid using incorrect cache code in ComparisonPredicate
    
    * recovery the regression test
---
 be/src/olap/comparison_predicate.h                 | 12 ++-
 .../test_schema_change_with_delete.groovy          | 92 +++++++++++-----------
 2 files changed, 54 insertions(+), 50 deletions(-)

diff --git a/be/src/olap/comparison_predicate.h 
b/be/src/olap/comparison_predicate.h
index 096ac11958..5bc9115399 100644
--- a/be/src/olap/comparison_predicate.h
+++ b/be/src/olap/comparison_predicate.h
@@ -37,10 +37,12 @@ public:
               _value(value) {}
 
     void clone(ColumnPredicate** to) const override {
-        *to = new ComparisonPredicateBase(_column_id, _value, _opposite);
-        (*to)->predicate_params()->value = _predicate_params->value;
-        (*to)->predicate_params()->marked_by_runtime_filter =
+        auto* cloned = new ComparisonPredicateBase(_column_id, _value, 
_opposite);
+        cloned->predicate_params()->value = _predicate_params->value;
+        cloned->_cache_code_enabled = true;
+        cloned->predicate_params()->marked_by_runtime_filter =
                 _predicate_params->marked_by_runtime_filter;
+        *to = cloned;
     }
 
     bool need_to_clone() const override { return true; }
@@ -555,7 +557,8 @@ private:
 
     __attribute__((flatten)) int32_t _find_code_from_dictionary_column(
             const vectorized::ColumnDictI32& column) const {
-        if (UNLIKELY(_cached_code == _InvalidateCodeValue)) {
+        /// if _cache_code_enabled is false, always find the code from dict.
+        if (UNLIKELY(!_cache_code_enabled || _cached_code == 
_InvalidateCodeValue)) {
             _cached_code = _is_range() ? column.find_code_by_bound(_value, 
_is_greater(), _is_eq())
                                        : column.find_code(_value);
         }
@@ -570,6 +573,7 @@ private:
 
     static constexpr int32_t _InvalidateCodeValue = 
std::numeric_limits<int32_t>::max();
     mutable int32_t _cached_code;
+    bool _cache_code_enabled = false;
     T _value;
 };
 
diff --git 
a/regression-test/suites/schema_change/test_schema_change_with_delete.groovy 
b/regression-test/suites/schema_change/test_schema_change_with_delete.groovy
index fab293438a..d40dcf1ebd 100644
--- a/regression-test/suites/schema_change/test_schema_change_with_delete.groovy
+++ b/regression-test/suites/schema_change/test_schema_change_with_delete.groovy
@@ -18,50 +18,50 @@
 // Test schema change for a table, the table has a delete predicate on string 
column
 suite("test_schema_change_with_delete") {
 
-//    def tbName = "test_schema_change_with_delete"
-//    def getJobState = { tableName ->
-//          def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
-//          return jobStateResult[0][9]
-//     }
-//
-//     sql """ DROP TABLE IF EXISTS ${tbName} FORCE"""
-//     // Create table and disable light weight schema change
-//     sql """
-//            CREATE TABLE IF NOT EXISTS ${tbName}
-//            (
-//                event_day int,
-//                siteid INT ,
-//                citycode int,
-//                username VARCHAR(32) DEFAULT ''
-//            )
-//            DUPLICATE  KEY(event_day,siteid)
-//            DISTRIBUTED BY HASH(event_day) BUCKETS 1
-//            PROPERTIES("replication_num" = "1", "light_schema_change" = 
"true");
-//         """
-//     sql """ insert into ${tbName} values(1, 1, 1, 'aaa');"""
-//     sql """ insert into ${tbName} values(2, 2, 2, 'bbb');"""
-//     sql """ delete from ${tbName} where username='aaa';"""
-//     sql """ insert into ${tbName} values(3, 3, 3, 'ccc');"""
-//
-//    qt_sql """select * from ${tbName} order by event_day;"""
-//
-//    // Change column type to string
-//    sql """ alter  table ${tbName} modify column citycode string """
-//
-//    int max_try_time = 1000
-//    while(max_try_time--){
-//          String result = getJobState(tbName)
-//          if (result == "FINISHED") {
-//               sleep(3000)
-//               break
-//          } else {
-//               sleep(100)
-//               if (max_try_time < 1){
-//                    assertEquals(1,2)
-//               }
-//          }
-//     }
-//    sql """ insert into ${tbName} values(4, 4, 'efg', 'ddd');"""
-//    qt_sql """select * from ${tbName} order by event_day;"""
-//    sql """ DROP TABLE  ${tbName} force"""
+   def tbName = "test_schema_change_with_delete"
+   def getJobState = { tableName ->
+         def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
+         return jobStateResult[0][9]
+    }
+
+    sql """ DROP TABLE IF EXISTS ${tbName} FORCE"""
+    // Create table and disable light weight schema change
+    sql """
+           CREATE TABLE IF NOT EXISTS ${tbName}
+           (
+               event_day int,
+               siteid INT ,
+               citycode int,
+               username VARCHAR(32) DEFAULT ''
+           )
+           DUPLICATE  KEY(event_day,siteid)
+           DISTRIBUTED BY HASH(event_day) BUCKETS 1
+           PROPERTIES("replication_num" = "1", "light_schema_change" = "true", 
"disable_auto_compaction" = "true");
+        """
+    sql """ insert into ${tbName} values(1, 1, 1, 'aaa');"""
+    sql """ insert into ${tbName} values(2, 2, 2, 'bbb');"""
+    sql """ delete from ${tbName} where username='aaa';"""
+    sql """ insert into ${tbName} values(3, 3, 3, 'ccc');"""
+
+   qt_sql """select * from ${tbName} order by event_day;"""
+
+   // Change column type to string
+   sql """ alter  table ${tbName} modify column citycode string """
+
+   int max_try_time = 1000
+   while(max_try_time--){
+         String result = getJobState(tbName)
+         if (result == "FINISHED") {
+              sleep(3000)
+              break
+         } else {
+              sleep(100)
+              if (max_try_time < 1){
+                   assertEquals(1,2)
+              }
+         }
+    }
+   sql """ insert into ${tbName} values(4, 4, 'efg', 'ddd');"""
+   qt_sql """select * from ${tbName} order by event_day;"""
+   sql """ DROP TABLE  ${tbName} force"""
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to