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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 11c40011505 Revert "[Coverage](BE) Delete vinfo_func in BE #26562 
(#26674)" (#26724)
11c40011505 is described below

commit 11c400115050fd07a7e4fc974bae3ea17504985c
Author: zclllyybb <[email protected]>
AuthorDate: Fri Nov 10 00:09:55 2023 +0800

    Revert "[Coverage](BE) Delete vinfo_func in BE #26562 (#26674)" (#26724)
    
    This reverts commit 22eafa4077d9a7e6f7f3d5bb18cabc6ba9002b65.
---
 be/src/vec/exprs/vexpr.cpp      |  5 +++
 be/src/vec/exprs/vinfo_func.cpp | 71 +++++++++++++++++++++++++++++++++++++++++
 be/src/vec/exprs/vinfo_func.h   | 52 ++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+)

diff --git a/be/src/vec/exprs/vexpr.cpp b/be/src/vec/exprs/vexpr.cpp
index 7f65dac9efc..75a21addb02 100644
--- a/be/src/vec/exprs/vexpr.cpp
+++ b/be/src/vec/exprs/vexpr.cpp
@@ -41,6 +41,7 @@
 #include "vec/exprs/vectorized_fn_call.h"
 #include "vec/exprs/vexpr_context.h"
 #include "vec/exprs/vin_predicate.h"
+#include "vec/exprs/vinfo_func.h"
 #include "vec/exprs/vlambda_function_call_expr.h"
 #include "vec/exprs/vlambda_function_expr.h"
 #include "vec/exprs/vliteral.h"
@@ -196,6 +197,10 @@ Status VExpr::create_expr(const TExprNode& expr_node, 
VExprSPtr& expr) {
             expr = VCaseExpr::create_shared(expr_node);
             break;
         }
+        case TExprNodeType::INFO_FUNC: {
+            expr = VInfoFunc::create_shared(expr_node);
+            break;
+        }
         case TExprNodeType::TUPLE_IS_NULL_PRED: {
             expr = VTupleIsNullPredicate::create_shared(expr_node);
             break;
diff --git a/be/src/vec/exprs/vinfo_func.cpp b/be/src/vec/exprs/vinfo_func.cpp
new file mode 100644
index 00000000000..c262882b317
--- /dev/null
+++ b/be/src/vec/exprs/vinfo_func.cpp
@@ -0,0 +1,71 @@
+// 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.
+
+#include "vec/exprs/vinfo_func.h"
+
+#include <gen_cpp/Exprs_types.h>
+#include <glog/logging.h>
+#include <stddef.h>
+
+#include <algorithm>
+#include <iostream>
+#include <memory>
+
+#include "runtime/define_primitive_type.h"
+#include "runtime/types.h"
+#include "vec/core/block.h"
+#include "vec/core/field.h"
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+
+namespace doris {
+namespace vectorized {
+class VExprContext;
+} // namespace vectorized
+} // namespace doris
+
+namespace doris::vectorized {
+
+VInfoFunc::VInfoFunc(const TExprNode& node) : VExpr(node) {
+    Field field;
+    switch (_type.type) {
+    case TYPE_BIGINT: {
+        field = Int64(node.info_func.int_value);
+        break;
+    }
+    case TYPE_STRING:
+    case TYPE_CHAR:
+    case TYPE_VARCHAR: {
+        field = node.info_func.str_value;
+        break;
+    }
+    default: {
+        DCHECK(false) << "Invalid type: " << _type.type;
+        break;
+    }
+    }
+    this->_column_ptr = _data_type->create_column_const(1, field);
+}
+
+Status VInfoFunc::execute(VExprContext* context, vectorized::Block* block, 
int* result_column_id) {
+    // Info function should return least one row, e.g. select current_user().
+    size_t row_size = std::max(block->rows(), size_t(1));
+    *result_column_id = VExpr::insert_param(block, {_column_ptr, _data_type, 
_expr_name}, row_size);
+    return Status::OK();
+}
+
+} // namespace doris::vectorized
diff --git a/be/src/vec/exprs/vinfo_func.h b/be/src/vec/exprs/vinfo_func.h
new file mode 100644
index 00000000000..54498272cff
--- /dev/null
+++ b/be/src/vec/exprs/vinfo_func.h
@@ -0,0 +1,52 @@
+// 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.
+
+#pragma once
+
+#include <string>
+
+#include "common/object_pool.h"
+#include "common/status.h"
+#include "vec/data_types/data_type.h"
+#include "vec/exprs/vexpr.h"
+
+namespace doris {
+class TExprNode;
+
+namespace vectorized {
+class Block;
+class VExprContext;
+
+class VInfoFunc : public VExpr {
+    ENABLE_FACTORY_CREATOR(VInfoFunc);
+
+public:
+    VInfoFunc(const TExprNode& node);
+    virtual ~VInfoFunc() {}
+
+    virtual VExprSPtr clone() const override { return 
VInfoFunc::create_shared(*this); }
+    virtual const std::string& expr_name() const override { return _expr_name; 
}
+    virtual Status execute(VExprContext* context, vectorized::Block* block,
+                           int* result_column_id) override;
+
+private:
+    const std::string _expr_name = "vinfofunc expr";
+    ColumnPtr _column_ptr;
+};
+} // namespace vectorized
+
+} // namespace doris


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

Reply via email to