morningman commented on a change in pull request #8448:
URL: https://github.com/apache/incubator-doris/pull/8448#discussion_r824671065



##########
File path: be/src/exec/table_function_node.h
##########
@@ -62,8 +59,11 @@ class TableFunctionNode : public ExecNode {
     bool _child_batch_exhausted = true;
 
     std::vector<ExprContext*> _fn_ctxs;
+    std::vector<vectorized::VExprContext*> _vfn_ctxs;
+
     std::vector<TableFunction*> _fns;
     std::vector<void*> _fn_values;
+    std::vector<int> _fn_value_lengths;

Review comment:
       use int64_t?

##########
File path: be/src/vec/exec/vtable_function_node.cpp
##########
@@ -0,0 +1,227 @@
+// 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/exec/vtable_function_node.h"
+
+#include "exprs/expr.h"
+#include "exprs/expr_context.h"
+#include "exprs/table_function/table_function.h"
+#include "exprs/table_function/table_function_factory.h"
+#include "vec/exprs/vexpr.h"
+
+namespace doris::vectorized {
+
+VTableFunctionNode::VTableFunctionNode(ObjectPool* pool, const TPlanNode& 
tnode,
+                                       const DescriptorTbl& descs)
+        : TableFunctionNode(pool, tnode, descs) {}
+
+Status VTableFunctionNode::init(const TPlanNode& tnode, RuntimeState* state) {
+    RETURN_IF_ERROR(ExecNode::init(tnode, state));
+
+    for (const TExpr& texpr : tnode.table_function_node.fnCallExprList) {
+        VExprContext* ctx = nullptr;
+        RETURN_IF_ERROR(VExpr::create_expr_tree(_pool, texpr, &ctx));
+        _vfn_ctxs.push_back(ctx);
+
+        VExpr* root = ctx->root();
+        const std::string& tf_name = root->fn().name.function_name;
+        TableFunction* fn = nullptr;
+        RETURN_IF_ERROR(TableFunctionFactory::get_fn("v" + tf_name, _pool, 
&fn));
+        fn->set_vexpr_context(ctx);
+        _fns.push_back(fn);
+    }
+    _fn_num = _fns.size();
+    _fn_values.resize(_fn_num);
+    _fn_value_lengths.resize(_fn_num);
+
+    // Prepare output slot ids
+    RETURN_IF_ERROR(_prepare_output_slot_ids(tnode));
+    return Status::OK();
+}
+
+Status VTableFunctionNode::prepare(RuntimeState* state) {
+    SCOPED_TIMER(_runtime_profile->total_time_counter());
+    RETURN_IF_ERROR(TableFunctionNode::prepare(state));
+    RETURN_IF_ERROR(VExpr::prepare(_vfn_ctxs, state, _row_descriptor, 
expr_mem_tracker()));
+
+    // get current all output slots
+    for (const auto& tuple_desc : this->row_desc().tuple_descriptors()) {
+        for (const auto& slot_desc : tuple_desc->slots()) {
+            _output_slots.push_back(slot_desc);
+        }
+    }
+
+    // get all input slots
+    for (const auto& child_tuple_desc : 
child(0)->row_desc().tuple_descriptors()) {
+        for (const auto& child_slot_desc : child_tuple_desc->slots()) {
+            _child_slots.push_back(child_slot_desc);
+        }
+    }
+
+    _child_block.reset(new Block());
+    _cur_child_offset = -1;
+
+    return Status::OK();
+}
+
+Status VTableFunctionNode::get_next(RuntimeState* state, Block* block, bool* 
eos) {
+    SCOPED_TIMER(_runtime_profile->total_time_counter());
+
+    if (state == nullptr || block == nullptr || eos == nullptr) {

Review comment:
       Is this check necessary?

##########
File path: be/src/vec/exec/vrepeat_node.cpp
##########
@@ -181,13 +187,9 @@ Status VRepeatNode::get_next(RuntimeState* state, Block* 
block, bool* eos) {
 
     // current child block has finished its repeat, get child's next block
     if (_child_block->rows() == 0) {
-        if (_child_eos) {

Review comment:
       Is this a bug before?

##########
File path: be/src/exprs/table_function/table_function_factory.cpp
##########
@@ -21,25 +21,30 @@
 #include "exprs/table_function/explode_bitmap.h"
 #include "exprs/table_function/explode_json_array.h"
 #include "exprs/table_function/explode_split.h"
+#include "vec/exprs/table_function/vexplode_split.h"
 
 namespace doris {
 
-Status TableFunctionFactory::get_fn(const std::string& fn_name, ObjectPool* 
pool, TableFunction** fn) {
+Status TableFunctionFactory::get_fn(const std::string& fn_name, ObjectPool* 
pool,
+                                    TableFunction** fn) {
     if (fn_name == "explode_split") {
         *fn = pool->add(new ExplodeSplitTableFunction());
-        return Status::OK(); 
+        return Status::OK();
+    } else if (fn_name == "vexplode_split") {
+        *fn = pool->add(new VExplodeSplitTableFunction());
+        return Status::OK();
     } else if (fn_name == "explode_bitmap") {
         *fn = pool->add(new ExplodeBitmapTableFunction());
-        return Status::OK(); 
+        return Status::OK();

Review comment:
       what about other table functions?




-- 
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]

Reply via email to