[Fix](status) fix unhandled status in exprs #28218
which marked static_cast<void> in https://github.com/apache/doris/pull/23395/files partially fixed #28160
This commit is contained in:
@ -38,6 +38,7 @@ class Exception : public std::exception {
|
||||
public:
|
||||
Exception() : _code(ErrorCode::OK) {}
|
||||
Exception(int code, const std::string_view& msg);
|
||||
Exception(const Status& status) : Exception(status.code(), status.msg()) {}
|
||||
// add nested exception as first param, or the template may could not find
|
||||
// the correct method for ...args
|
||||
Exception(const Exception& nested, int code, const std::string_view& msg);
|
||||
|
||||
@ -537,6 +537,14 @@ inline std::string Status::to_string_no_stack() const {
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define THROW_IF_ERROR(stmt) \
|
||||
do { \
|
||||
Status _status_ = (stmt); \
|
||||
if (UNLIKELY(!_status_.ok())) { \
|
||||
throw Exception(_status_); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define RETURN_ERROR_IF_NON_VEC \
|
||||
return Status::NotSupported("Non-vectorized engine is not supported since Doris 2.0.");
|
||||
|
||||
|
||||
@ -208,9 +208,8 @@ PFilterType get_type(RuntimeFilterType type) {
|
||||
}
|
||||
|
||||
Status create_literal(const TypeDescriptor& type, const void* data, vectorized::VExprSPtr& expr) {
|
||||
TExprNode node = create_texpr_node_from(data, type.type, type.precision, type.scale);
|
||||
|
||||
try {
|
||||
TExprNode node = create_texpr_node_from(data, type.type, type.precision, type.scale);
|
||||
expr = vectorized::VLiteral::create_shared(node);
|
||||
} catch (const Exception& e) {
|
||||
return e.to_status();
|
||||
|
||||
@ -115,7 +115,7 @@ int TableFunctionLocalState::_find_last_fn_eos_idx() const {
|
||||
bool TableFunctionLocalState::_roll_table_functions(int last_eos_idx) {
|
||||
int i = last_eos_idx - 1;
|
||||
for (; i >= 0; --i) {
|
||||
static_cast<void>(_fns[i]->forward());
|
||||
_fns[i]->forward();
|
||||
if (!_fns[i]->eos()) {
|
||||
break;
|
||||
}
|
||||
@ -127,7 +127,7 @@ bool TableFunctionLocalState::_roll_table_functions(int last_eos_idx) {
|
||||
}
|
||||
|
||||
for (int j = i + 1; j < _parent->cast<TableFunctionOperatorX>()._fn_num; ++j) {
|
||||
static_cast<void>(_fns[j]->reset());
|
||||
_fns[j]->reset();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -171,7 +171,7 @@ Status TableFunctionLocalState::get_expanded_block(RuntimeState* state,
|
||||
if (idx == 0 || skip_child_row) {
|
||||
_copy_output_slots(columns);
|
||||
// all table functions' results are exhausted, process next child row.
|
||||
RETURN_IF_ERROR(process_next_child_row());
|
||||
process_next_child_row();
|
||||
if (_cur_child_offset == -1) {
|
||||
break;
|
||||
}
|
||||
@ -196,7 +196,7 @@ Status TableFunctionLocalState::get_expanded_block(RuntimeState* state,
|
||||
_fns[i]->get_value(columns[i + p._child_slots.size()]);
|
||||
}
|
||||
_current_row_insert_times++;
|
||||
static_cast<void>(_fns[p._fn_num - 1]->forward());
|
||||
_fns[p._fn_num - 1]->forward();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -218,27 +218,25 @@ Status TableFunctionLocalState::get_expanded_block(RuntimeState* state,
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status TableFunctionLocalState::process_next_child_row() {
|
||||
void TableFunctionLocalState::process_next_child_row() {
|
||||
_cur_child_offset++;
|
||||
|
||||
if (_cur_child_offset >= _child_block->rows()) {
|
||||
// release block use count.
|
||||
for (vectorized::TableFunction* fn : _fns) {
|
||||
RETURN_IF_ERROR(fn->process_close());
|
||||
fn->process_close();
|
||||
}
|
||||
|
||||
_child_block->clear_column_data(_parent->cast<TableFunctionOperatorX>()
|
||||
._child_x->row_desc()
|
||||
.num_materialized_slots());
|
||||
_cur_child_offset = -1;
|
||||
return Status::OK();
|
||||
return;
|
||||
}
|
||||
|
||||
for (vectorized::TableFunction* fn : _fns) {
|
||||
RETURN_IF_ERROR(fn->process_row(_cur_child_offset));
|
||||
fn->process_row(_cur_child_offset);
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
TableFunctionOperatorX::TableFunctionOperatorX(ObjectPool* pool, const TPlanNode& tnode,
|
||||
@ -289,7 +287,7 @@ Status TableFunctionOperatorX::init(const TPlanNode& tnode, RuntimeState* state)
|
||||
Status TableFunctionOperatorX::prepare(RuntimeState* state) {
|
||||
RETURN_IF_ERROR(Base::prepare(state));
|
||||
|
||||
for (auto fn : _fns) {
|
||||
for (auto* fn : _fns) {
|
||||
RETURN_IF_ERROR(fn->prepare());
|
||||
}
|
||||
RETURN_IF_ERROR(vectorized::VExpr::prepare(_vfn_ctxs, state, _row_descriptor));
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
~TableFunctionLocalState() override = default;
|
||||
|
||||
Status init(RuntimeState* state, LocalStateInfo& info) override;
|
||||
Status process_next_child_row();
|
||||
void process_next_child_row();
|
||||
Status get_expanded_block(RuntimeState* state, vectorized::Block* output_block,
|
||||
SourceState& source_state);
|
||||
|
||||
@ -106,7 +106,7 @@ public:
|
||||
for (auto* fn : local_state._fns) {
|
||||
RETURN_IF_ERROR(fn->process_init(input_block, state));
|
||||
}
|
||||
RETURN_IF_ERROR(local_state.process_next_child_row());
|
||||
local_state.process_next_child_row();
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ Status VTableFunctionNode::prepare(RuntimeState* state) {
|
||||
SCOPED_TIMER(_exec_timer);
|
||||
|
||||
_num_rows_filtered_counter = ADD_COUNTER(_runtime_profile, "RowsFiltered", TUnit::UNIT);
|
||||
for (auto fn : _fns) {
|
||||
for (auto* fn : _fns) {
|
||||
RETURN_IF_ERROR(fn->prepare());
|
||||
}
|
||||
RETURN_IF_ERROR(VExpr::prepare(_vfn_ctxs, state, _row_descriptor));
|
||||
@ -182,7 +182,7 @@ Status VTableFunctionNode::_get_expanded_block(RuntimeState* state, Block* outpu
|
||||
if (idx == 0 || skip_child_row) {
|
||||
_copy_output_slots(columns);
|
||||
// all table functions' results are exhausted, process next child row.
|
||||
RETURN_IF_ERROR(_process_next_child_row());
|
||||
_process_next_child_row();
|
||||
if (_cur_child_offset == -1) {
|
||||
break;
|
||||
}
|
||||
@ -207,7 +207,7 @@ Status VTableFunctionNode::_get_expanded_block(RuntimeState* state, Block* outpu
|
||||
_fns[i]->get_value(columns[i + _child_slots.size()]);
|
||||
}
|
||||
_current_row_insert_times++;
|
||||
static_cast<void>(_fns[_fn_num - 1]->forward());
|
||||
_fns[_fn_num - 1]->forward();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -226,25 +226,23 @@ Status VTableFunctionNode::_get_expanded_block(RuntimeState* state, Block* outpu
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VTableFunctionNode::_process_next_child_row() {
|
||||
void VTableFunctionNode::_process_next_child_row() {
|
||||
_cur_child_offset++;
|
||||
|
||||
if (_cur_child_offset >= _child_block->rows()) {
|
||||
// release block use count.
|
||||
for (TableFunction* fn : _fns) {
|
||||
RETURN_IF_ERROR(fn->process_close());
|
||||
fn->process_close();
|
||||
}
|
||||
|
||||
release_block_memory(*_child_block);
|
||||
_cur_child_offset = -1;
|
||||
return Status::OK();
|
||||
return;
|
||||
}
|
||||
|
||||
for (TableFunction* fn : _fns) {
|
||||
RETURN_IF_ERROR(fn->process_row(_cur_child_offset));
|
||||
fn->process_row(_cur_child_offset);
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
// Returns the index of fn of the last eos counted from back to front
|
||||
@ -287,7 +285,7 @@ int VTableFunctionNode::_find_last_fn_eos_idx() {
|
||||
bool VTableFunctionNode::_roll_table_functions(int last_eos_idx) {
|
||||
int i = last_eos_idx - 1;
|
||||
for (; i >= 0; --i) {
|
||||
static_cast<void>(_fns[i]->forward());
|
||||
_fns[i]->forward();
|
||||
if (!_fns[i]->eos()) {
|
||||
break;
|
||||
}
|
||||
@ -299,7 +297,7 @@ bool VTableFunctionNode::_roll_table_functions(int last_eos_idx) {
|
||||
}
|
||||
|
||||
for (int j = i + 1; j < _fn_num; ++j) {
|
||||
static_cast<void>(_fns[j]->reset());
|
||||
_fns[j]->reset();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -17,8 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "common/global_types.h"
|
||||
@ -81,7 +80,7 @@ public:
|
||||
for (TableFunction* fn : _fns) {
|
||||
RETURN_IF_ERROR(fn->process_init(input_block, state));
|
||||
}
|
||||
RETURN_IF_ERROR(_process_next_child_row());
|
||||
_process_next_child_row();
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -106,7 +105,7 @@ private:
|
||||
|
||||
bool _roll_table_functions(int last_eos_idx);
|
||||
|
||||
Status _process_next_child_row();
|
||||
void _process_next_child_row();
|
||||
|
||||
/* Now the output tuples for table function node is base_table_tuple + tf1 + tf2 + ...
|
||||
But not all slots are used, the real used slots are inside table_function_node.outputSlotIds.
|
||||
|
||||
@ -38,20 +38,19 @@ public:
|
||||
|
||||
virtual Status process_init(Block* block, RuntimeState* state) = 0;
|
||||
|
||||
virtual Status process_row(size_t row_idx) {
|
||||
virtual void process_row(size_t row_idx) {
|
||||
if (!_is_const) {
|
||||
_cur_size = 0;
|
||||
}
|
||||
return reset();
|
||||
reset();
|
||||
}
|
||||
|
||||
// only used for vectorized.
|
||||
virtual Status process_close() = 0;
|
||||
virtual void process_close() = 0;
|
||||
|
||||
virtual Status reset() {
|
||||
virtual void reset() {
|
||||
_eos = false;
|
||||
_cur_offset = 0;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
virtual void get_value(MutableColumnPtr& column) = 0;
|
||||
@ -61,14 +60,14 @@ public:
|
||||
int i = 0;
|
||||
for (; i < max_step && !eos(); i++) {
|
||||
get_value(column);
|
||||
static_cast<void>(forward());
|
||||
forward();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
virtual Status close() { return Status::OK(); }
|
||||
|
||||
virtual Status forward(int step = 1) {
|
||||
virtual void forward(int step = 1) {
|
||||
if (current_empty()) {
|
||||
_eos = true;
|
||||
} else {
|
||||
@ -77,7 +76,6 @@ public:
|
||||
_eos = true;
|
||||
}
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
std::string name() const { return _fn_name; }
|
||||
|
||||
@ -56,22 +56,20 @@ Status VExplodeTableFunction::process_init(Block* block, RuntimeState* state) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeTableFunction::process_row(size_t row_idx) {
|
||||
void VExplodeTableFunction::process_row(size_t row_idx) {
|
||||
DCHECK(row_idx < _array_column->size());
|
||||
RETURN_IF_ERROR(TableFunction::process_row(row_idx));
|
||||
TableFunction::process_row(row_idx);
|
||||
|
||||
if (!_detail.array_nullmap_data || !_detail.array_nullmap_data[row_idx]) {
|
||||
_array_offset = (*_detail.offsets_ptr)[row_idx - 1];
|
||||
_cur_size = (*_detail.offsets_ptr)[row_idx] - _array_offset;
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeTableFunction::process_close() {
|
||||
void VExplodeTableFunction::process_close() {
|
||||
_array_column = nullptr;
|
||||
_detail.reset();
|
||||
_array_offset = 0;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void VExplodeTableFunction::get_value(MutableColumnPtr& column) {
|
||||
|
||||
@ -41,8 +41,8 @@ public:
|
||||
~VExplodeTableFunction() override = default;
|
||||
|
||||
Status process_init(Block* block, RuntimeState* state) override;
|
||||
Status process_row(size_t row_idx) override;
|
||||
Status process_close() override;
|
||||
void process_row(size_t row_idx) override;
|
||||
void process_close() override;
|
||||
void get_value(MutableColumnPtr& column) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
@ -53,22 +54,21 @@ Status VExplodeBitmapTableFunction::process_init(Block* block, RuntimeState* sta
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeBitmapTableFunction::reset() {
|
||||
void VExplodeBitmapTableFunction::reset() {
|
||||
_eos = false;
|
||||
_cur_offset = 0;
|
||||
if (!current_empty()) {
|
||||
_cur_iter.reset(new BitmapValueIterator(*_cur_bitmap));
|
||||
_cur_iter = std::make_unique<BitmapValueIterator>(*_cur_bitmap);
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeBitmapTableFunction::forward(int step) {
|
||||
void VExplodeBitmapTableFunction::forward(int step) {
|
||||
if (!current_empty()) {
|
||||
for (int i = 0; i < step; i++) {
|
||||
++(*_cur_iter);
|
||||
}
|
||||
}
|
||||
return TableFunction::forward(step);
|
||||
TableFunction::forward(step);
|
||||
}
|
||||
|
||||
void VExplodeBitmapTableFunction::get_value(MutableColumnPtr& column) {
|
||||
@ -88,8 +88,8 @@ void VExplodeBitmapTableFunction::get_value(MutableColumnPtr& column) {
|
||||
}
|
||||
}
|
||||
|
||||
Status VExplodeBitmapTableFunction::process_row(size_t row_idx) {
|
||||
RETURN_IF_ERROR(TableFunction::process_row(row_idx));
|
||||
void VExplodeBitmapTableFunction::process_row(size_t row_idx) {
|
||||
TableFunction::process_row(row_idx);
|
||||
|
||||
StringRef value = _value_column->get_data_at(row_idx);
|
||||
|
||||
@ -98,16 +98,13 @@ Status VExplodeBitmapTableFunction::process_row(size_t row_idx) {
|
||||
|
||||
_cur_size = _cur_bitmap->cardinality();
|
||||
if (!current_empty()) {
|
||||
_cur_iter.reset(new BitmapValueIterator(*_cur_bitmap));
|
||||
_cur_iter = std::make_unique<BitmapValueIterator>(*_cur_bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeBitmapTableFunction::process_close() {
|
||||
void VExplodeBitmapTableFunction::process_close() {
|
||||
_value_column = nullptr;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace doris::vectorized
|
||||
|
||||
@ -41,13 +41,13 @@ public:
|
||||
VExplodeBitmapTableFunction();
|
||||
~VExplodeBitmapTableFunction() override = default;
|
||||
|
||||
Status reset() override;
|
||||
void reset() override;
|
||||
void get_value(MutableColumnPtr& column) override;
|
||||
Status forward(int step = 1) override;
|
||||
void forward(int step = 1) override;
|
||||
|
||||
Status process_init(Block* block, RuntimeState* state) override;
|
||||
Status process_row(size_t row_idx) override;
|
||||
Status process_close() override;
|
||||
void process_row(size_t row_idx) override;
|
||||
void process_close() override;
|
||||
|
||||
private:
|
||||
void _reset_iterator();
|
||||
|
||||
@ -195,8 +195,8 @@ Status VExplodeJsonArrayTableFunction::process_init(Block* block, RuntimeState*
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeJsonArrayTableFunction::process_row(size_t row_idx) {
|
||||
RETURN_IF_ERROR(TableFunction::process_row(row_idx));
|
||||
void VExplodeJsonArrayTableFunction::process_row(size_t row_idx) {
|
||||
TableFunction::process_row(row_idx);
|
||||
|
||||
StringRef text = _text_column->get_data_at(row_idx);
|
||||
if (text.data != nullptr) {
|
||||
@ -206,12 +206,10 @@ Status VExplodeJsonArrayTableFunction::process_row(size_t row_idx) {
|
||||
_cur_size = _parsed_data.set_output(_type, document);
|
||||
}
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeJsonArrayTableFunction::process_close() {
|
||||
void VExplodeJsonArrayTableFunction::process_close() {
|
||||
_text_column = nullptr;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void VExplodeJsonArrayTableFunction::get_value(MutableColumnPtr& column) {
|
||||
|
||||
@ -90,8 +90,8 @@ public:
|
||||
~VExplodeJsonArrayTableFunction() override = default;
|
||||
|
||||
Status process_init(Block* block, RuntimeState* state) override;
|
||||
Status process_row(size_t row_idx) override;
|
||||
Status process_close() override;
|
||||
void process_row(size_t row_idx) override;
|
||||
void process_close() override;
|
||||
void get_value(MutableColumnPtr& column) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -76,22 +76,20 @@ Status VExplodeNumbersTableFunction::process_init(Block* block, RuntimeState* st
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeNumbersTableFunction::process_row(size_t row_idx) {
|
||||
RETURN_IF_ERROR(TableFunction::process_row(row_idx));
|
||||
void VExplodeNumbersTableFunction::process_row(size_t row_idx) {
|
||||
TableFunction::process_row(row_idx);
|
||||
if (_is_const) {
|
||||
return Status::OK();
|
||||
return;
|
||||
}
|
||||
|
||||
StringRef value = _value_column->get_data_at(row_idx);
|
||||
if (value.data != nullptr) {
|
||||
_cur_size = std::max(0, *reinterpret_cast<const int*>(value.data));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeNumbersTableFunction::process_close() {
|
||||
void VExplodeNumbersTableFunction::process_close() {
|
||||
_value_column = nullptr;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void VExplodeNumbersTableFunction::get_value(MutableColumnPtr& column) {
|
||||
|
||||
@ -44,8 +44,8 @@ public:
|
||||
~VExplodeNumbersTableFunction() override = default;
|
||||
|
||||
Status process_init(Block* block, RuntimeState* state) override;
|
||||
Status process_row(size_t row_idx) override;
|
||||
Status process_close() override;
|
||||
void process_row(size_t row_idx) override;
|
||||
void process_close() override;
|
||||
void get_value(MutableColumnPtr& column) override;
|
||||
int get_value(MutableColumnPtr& column, int max_step) override {
|
||||
if (_is_const) {
|
||||
@ -62,7 +62,7 @@ public:
|
||||
->insert_range_from(*_elements_column, _cur_offset, max_step);
|
||||
}
|
||||
|
||||
static_cast<void>(forward(max_step));
|
||||
forward(max_step);
|
||||
return max_step;
|
||||
}
|
||||
|
||||
|
||||
@ -83,18 +83,18 @@ Status VExplodeSplitTableFunction::process_init(Block* block, RuntimeState* stat
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeSplitTableFunction::process_row(size_t row_idx) {
|
||||
RETURN_IF_ERROR(TableFunction::process_row(row_idx));
|
||||
void VExplodeSplitTableFunction::process_row(size_t row_idx) {
|
||||
TableFunction::process_row(row_idx);
|
||||
|
||||
if (!(_test_null_map && _test_null_map[row_idx]) && _delimiter.data != nullptr) {
|
||||
// TODO: use the function to be better string_view/StringRef split
|
||||
auto split = [](std::string_view strv, std::string_view delims = " ") {
|
||||
std::vector<std::string_view> output;
|
||||
auto first = strv.begin();
|
||||
auto last = strv.end();
|
||||
const auto* first = strv.begin();
|
||||
const auto* last = strv.end();
|
||||
|
||||
do {
|
||||
const auto second =
|
||||
const auto* second =
|
||||
std::search(first, last, std::cbegin(delims), std::cend(delims));
|
||||
if (first != second) {
|
||||
output.emplace_back(strv.substr(std::distance(strv.begin(), first),
|
||||
@ -115,15 +115,13 @@ Status VExplodeSplitTableFunction::process_row(size_t row_idx) {
|
||||
|
||||
_cur_size = _backup.size();
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status VExplodeSplitTableFunction::process_close() {
|
||||
void VExplodeSplitTableFunction::process_close() {
|
||||
_text_column = nullptr;
|
||||
_real_text_column = nullptr;
|
||||
_test_null_map = nullptr;
|
||||
_delimiter = {};
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void VExplodeSplitTableFunction::get_value(MutableColumnPtr& column) {
|
||||
|
||||
@ -46,8 +46,8 @@ public:
|
||||
|
||||
Status open() override;
|
||||
Status process_init(Block* block, RuntimeState* state) override;
|
||||
Status process_row(size_t row_idx) override;
|
||||
Status process_close() override;
|
||||
void process_row(size_t row_idx) override;
|
||||
void process_close() override;
|
||||
void get_value(MutableColumnPtr& column) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -66,11 +66,7 @@ AggregateFunctionPtr get_agg_state_function(const DataTypes& argument_types,
|
||||
AggFnEvaluator::AggFnEvaluator(const TExprNode& desc)
|
||||
: _fn(desc.fn),
|
||||
_is_merge(desc.agg_expr.is_merge_agg),
|
||||
_return_type(TypeDescriptor::from_thrift(desc.fn.ret_type)),
|
||||
_intermediate_slot_desc(nullptr),
|
||||
_output_slot_desc(nullptr),
|
||||
_merge_timer(nullptr),
|
||||
_expr_timer(nullptr) {
|
||||
_return_type(TypeDescriptor::from_thrift(desc.fn.ret_type)) {
|
||||
bool nullable = true;
|
||||
if (desc.__isset.is_nullable) {
|
||||
nullable = desc.is_nullable;
|
||||
@ -78,10 +74,10 @@ AggFnEvaluator::AggFnEvaluator(const TExprNode& desc)
|
||||
_data_type = DataTypeFactory::instance().create_data_type(_return_type, nullable);
|
||||
|
||||
if (desc.agg_expr.__isset.param_types) {
|
||||
auto& param_types = desc.agg_expr.param_types;
|
||||
for (int i = 0; i < param_types.size(); i++) {
|
||||
const auto& param_types = desc.agg_expr.param_types;
|
||||
for (const auto& param_type : param_types) {
|
||||
_argument_types_with_sort.push_back(
|
||||
DataTypeFactory::instance().create_data_type(param_types[i]));
|
||||
DataTypeFactory::instance().create_data_type(param_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,10 +130,10 @@ Status AggFnEvaluator::prepare(RuntimeState* state, const RowDescriptor& desc,
|
||||
std::vector<std::string_view> child_expr_name;
|
||||
|
||||
// prepare for argument
|
||||
for (int i = 0; i < _input_exprs_ctxs.size(); ++i) {
|
||||
auto data_type = _input_exprs_ctxs[i]->root()->data_type();
|
||||
for (auto& _input_exprs_ctx : _input_exprs_ctxs) {
|
||||
auto data_type = _input_exprs_ctx->root()->data_type();
|
||||
tmp_argument_types.emplace_back(data_type);
|
||||
child_expr_name.emplace_back(_input_exprs_ctxs[i]->root()->expr_name());
|
||||
child_expr_name.emplace_back(_input_exprs_ctx->root()->expr_name());
|
||||
}
|
||||
|
||||
const DataTypes& argument_types =
|
||||
@ -334,15 +330,14 @@ AggFnEvaluator::AggFnEvaluator(AggFnEvaluator& evaluator, RuntimeState* state)
|
||||
DataTypes tmp_argument_types;
|
||||
tmp_argument_types.reserve(evaluator._input_exprs_ctxs.size());
|
||||
// prepare for argument
|
||||
for (int i = 0; i < evaluator._input_exprs_ctxs.size(); ++i) {
|
||||
auto data_type = evaluator._input_exprs_ctxs[i]->root()->data_type();
|
||||
for (auto& _input_exprs_ctx : evaluator._input_exprs_ctxs) {
|
||||
auto data_type = _input_exprs_ctx->root()->data_type();
|
||||
tmp_argument_types.emplace_back(data_type);
|
||||
}
|
||||
const DataTypes& argument_types =
|
||||
_real_argument_types.empty() ? tmp_argument_types : _real_argument_types;
|
||||
_function = AggregateJavaUdaf::create(evaluator._fn, argument_types, evaluator._data_type);
|
||||
static_cast<void>(
|
||||
static_cast<AggregateJavaUdaf*>(_function.get())->check_udaf(evaluator._fn));
|
||||
THROW_IF_ERROR(static_cast<AggregateJavaUdaf*>(_function.get())->check_udaf(evaluator._fn));
|
||||
}
|
||||
DCHECK(_function != nullptr);
|
||||
|
||||
|
||||
@ -61,85 +61,83 @@ TExprNode create_texpr_node_from(const void* data, const PrimitiveType& type, in
|
||||
|
||||
switch (type) {
|
||||
case TYPE_BOOLEAN: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_BOOLEAN>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_BOOLEAN>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_TINYINT: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_TINYINT>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_TINYINT>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_SMALLINT: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_SMALLINT>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_SMALLINT>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_INT: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_INT>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_INT>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_BIGINT: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_BIGINT>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_BIGINT>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_LARGEINT: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_LARGEINT>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_LARGEINT>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_FLOAT: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_FLOAT>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_FLOAT>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_DOUBLE: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DOUBLE>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DOUBLE>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_DATEV2: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DATEV2>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATEV2>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_DATETIMEV2: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DATETIMEV2>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATETIMEV2>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_DATE: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DATE>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATE>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_DATETIME: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DATETIME>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATETIME>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_DECIMALV2: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DECIMALV2>(data, &node, precision, scale));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMALV2>(data, &node, precision, scale));
|
||||
break;
|
||||
}
|
||||
case TYPE_DECIMAL32: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DECIMAL32>(data, &node, precision, scale));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL32>(data, &node, precision, scale));
|
||||
break;
|
||||
}
|
||||
case TYPE_DECIMAL64: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_DECIMAL64>(data, &node, precision, scale));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL64>(data, &node, precision, scale));
|
||||
break;
|
||||
}
|
||||
case TYPE_DECIMAL128I: {
|
||||
static_cast<void>(
|
||||
create_texpr_literal_node<TYPE_DECIMAL128I>(data, &node, precision, scale));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL128I>(data, &node, precision, scale));
|
||||
break;
|
||||
}
|
||||
case TYPE_DECIMAL256: {
|
||||
static_cast<void>(
|
||||
create_texpr_literal_node<TYPE_DECIMAL256>(data, &node, precision, scale));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL256>(data, &node, precision, scale));
|
||||
break;
|
||||
}
|
||||
case TYPE_CHAR: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_CHAR>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_CHAR>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_VARCHAR: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_VARCHAR>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_VARCHAR>(data, &node));
|
||||
break;
|
||||
}
|
||||
case TYPE_STRING: {
|
||||
static_cast<void>(create_texpr_literal_node<TYPE_STRING>(data, &node));
|
||||
THROW_IF_ERROR(create_texpr_literal_node<TYPE_STRING>(data, &node));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -541,9 +539,10 @@ void VExpr::close_function_context(VExprContext* context, FunctionContext::Funct
|
||||
const FunctionBasePtr& function) const {
|
||||
if (_fn_context_index != -1) {
|
||||
FunctionContext* fn_ctx = context->fn_context(_fn_context_index);
|
||||
static_cast<void>(function->close(fn_ctx, FunctionContext::THREAD_LOCAL));
|
||||
// close failed will make system unstable. dont swallow it.
|
||||
THROW_IF_ERROR(function->close(fn_ctx, FunctionContext::THREAD_LOCAL));
|
||||
if (scope == FunctionContext::FRAGMENT_LOCAL) {
|
||||
static_cast<void>(function->close(fn_ctx, FunctionContext::FRAGMENT_LOCAL));
|
||||
THROW_IF_ERROR(function->close(fn_ctx, FunctionContext::FRAGMENT_LOCAL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,10 +356,7 @@ Block* process_table_function(TableFunction* fn, Block* input_block,
|
||||
|
||||
// process table function for all rows
|
||||
for (size_t row = 0; row < input_block->rows(); ++row) {
|
||||
if (fn->process_row(row) != Status::OK()) {
|
||||
LOG(WARNING) << "TableFunction process_row failed";
|
||||
return nullptr;
|
||||
}
|
||||
fn->process_row(row);
|
||||
|
||||
// consider outer
|
||||
if (!fn->is_outer() && fn->current_empty()) {
|
||||
@ -368,7 +365,7 @@ Block* process_table_function(TableFunction* fn, Block* input_block,
|
||||
|
||||
do {
|
||||
fn->get_value(column);
|
||||
static_cast<void>(fn->forward());
|
||||
fn->forward();
|
||||
} while (!fn->eos());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user