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

yangzhg 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 b3c6af0059 [Bugfix](MV) Fixed load negative values into bitmap type 
materialized views successfully under non-vectorization (#13719)
b3c6af0059 is described below

commit b3c6af00593eaa1323e455f572d0ba4895e899a1
Author: Zhengguo Yang <yangz...@gmail.com>
AuthorDate: Thu Nov 3 09:21:38 2022 +0800

    [Bugfix](MV) Fixed load negative values into bitmap type materialized views 
successfully under non-vectorization (#13719)
    
    * [Bugfix](MV) Fixed load negative values into bitmap type materialized 
views successfully under non-vectorization
---
 be/src/exprs/bitmap_function.cpp                   |  2 +-
 .../doris/analysis/CreateMaterializedViewStmt.java | 40 ++++++++++++----------
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/be/src/exprs/bitmap_function.cpp b/be/src/exprs/bitmap_function.cpp
index 7254dc3a45..1d4fc4df47 100644
--- a/be/src/exprs/bitmap_function.cpp
+++ b/be/src/exprs/bitmap_function.cpp
@@ -190,7 +190,7 @@ StringVal 
BitmapFunctions::to_bitmap_with_check(doris_udf::FunctionContext* ctx,
                   "18446744073709551615 currently, cannot load negative values 
to column with"
                   " to_bitmap MV on it.";
             ctx->set_error(ss.str().c_str());
-            return serialize(ctx, nullptr);
+            return StringVal::null();
         }
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
index 8651a2eee8..515e18aab1 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
@@ -137,6 +137,7 @@ public class CreateMaterializedViewStmt extends DdlStmt {
     public void analyze(Analyzer analyzer) throws UserException {
         super.analyze(analyzer);
         FeNameFormat.checkTableName(mvName);
+        rewriteToBitmapWithCheck();
         // TODO(ml): The mv name in from clause should pass the analyze 
without error.
         selectStmt.forbiddenMVRewrite();
         selectStmt.analyze(analyzer);
@@ -211,25 +212,6 @@ public class CreateMaterializedViewStmt extends DdlStmt {
                         throw new AnalysisException(
                                 "The function " + functionName + " must match 
pattern:" + mvColumnPattern.toString());
                     }
-
-                    // for bitmap_union(to_bitmap(column)) function, we should 
check value is not negative
-                    // in vectorized schema_change mode, so we should rewrite 
the function to
-                    // bitmap_union(to_bitmap_with_check(column))
-                    if (functionName.equalsIgnoreCase("bitmap_union")) {
-                        if (functionCallExpr.getChildren().size() == 1
-                                && functionCallExpr.getChild(0) instanceof 
FunctionCallExpr) {
-                            Expr child = functionCallExpr.getChild(0);
-                            FunctionCallExpr childFunctionCallExpr = 
(FunctionCallExpr) child;
-                            if 
(childFunctionCallExpr.getFnName().getFunction().equalsIgnoreCase("to_bitmap")) 
{
-                                childFunctionCallExpr.setFnName(
-                                        new 
FunctionName(childFunctionCallExpr.getFnName().getDb(),
-                                                "to_bitmap_with_check"));
-                                childFunctionCallExpr.getFn().setName(
-                                        new 
FunctionName(childFunctionCallExpr.getFn().getFunctionName().getDb(),
-                                                "to_bitmap_with_check"));
-                            }
-                        }
-                    }
                 }
                 // check duplicate column
                 List<SlotRef> slots = new ArrayList<>();
@@ -504,6 +486,26 @@ public class CreateMaterializedViewStmt extends DdlStmt {
         return result;
     }
 
+    // for bitmap_union(to_bitmap(column)) function, we should check value is 
not negative
+    // in vectorized schema_change mode, so we should rewrite the function to
+    // bitmap_union(to_bitmap_with_check(column))
+    private void rewriteToBitmapWithCheck() {
+        for (SelectListItem item : selectStmt.getSelectList().getItems()) {
+            if (item.getExpr() instanceof FunctionCallExpr) {
+                String functionName = ((FunctionCallExpr) 
item.getExpr()).getFnName().getFunction();
+                if (functionName.equalsIgnoreCase("bitmap_union")) {
+                    if (item.getExpr().getChildren().size() == 1
+                            && item.getExpr().getChild(0) instanceof 
FunctionCallExpr) {
+                        FunctionCallExpr childFunctionCallExpr = 
(FunctionCallExpr) item.getExpr().getChild(0);
+                        if 
(childFunctionCallExpr.getFnName().getFunction().equalsIgnoreCase("to_bitmap")) 
{
+                            
childFunctionCallExpr.setFnName(FunctionName.createBuiltinName("to_bitmap_with_check"));
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     public static String mvColumnBuilder(String functionName, String 
sourceColumnName) {
         return new 
StringBuilder().append(MATERIALIZED_VIEW_NAME_PREFIX).append(functionName).append("_")
                 .append(sourceColumnName).toString();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to