diff --git a/be/src/vec/exprs/table_function/table_function.h b/be/src/vec/exprs/table_function/table_function.h index bd926c365704fd..ef36ca881d79ab 100644 --- a/be/src/vec/exprs/table_function/table_function.h +++ b/be/src/vec/exprs/table_function/table_function.h @@ -18,13 +18,15 @@ #pragma once #include -#include + +#include #include "common/status.h" #include "vec/core/block.h" #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" constexpr auto COMBINATOR_SUFFIX_OUTER = "_outer"; @@ -101,4 +103,6 @@ class TableFunction { bool _is_nullable = false; bool _is_const = false; }; + +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/table_function_factory.cpp b/be/src/vec/exprs/table_function/table_function_factory.cpp index 332eaed37d4483..ad080e491512cb 100644 --- a/be/src/vec/exprs/table_function/table_function_factory.cpp +++ b/be/src/vec/exprs/table_function/table_function_factory.cpp @@ -21,7 +21,6 @@ #include #include -#include #include "common/object_pool.h" #include "vec/exprs/table_function/table_function.h" @@ -37,6 +36,7 @@ #include "vec/utils/util.hpp" namespace doris::vectorized { +#include "common/compile_check_begin.h" template struct TableFunctionCreator { @@ -91,4 +91,5 @@ Status TableFunctionFactory::get_fn(const TFunction& t_fn, ObjectPool* pool, Tab return Status::NotSupported("Table function {} is not support", t_fn.name.function_name); } +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/table_function_factory.h b/be/src/vec/exprs/table_function/table_function_factory.h index cd06c202f3778c..617d5e9583eff1 100644 --- a/be/src/vec/exprs/table_function/table_function_factory.h +++ b/be/src/vec/exprs/table_function/table_function_factory.h @@ -27,6 +27,8 @@ #include "common/status.h" namespace doris { +#include "common/compile_check_begin.h" + class ObjectPool; namespace vectorized { @@ -41,4 +43,5 @@ class TableFunctionFactory { _function_map; }; } // namespace vectorized +#include "common/compile_check_end.h" } // namespace doris diff --git a/be/src/vec/exprs/table_function/udf_table_function.cpp b/be/src/vec/exprs/table_function/udf_table_function.cpp index 9aa850d68b7d20..237b6806da675c 100644 --- a/be/src/vec/exprs/table_function/udf_table_function.cpp +++ b/be/src/vec/exprs/table_function/udf_table_function.cpp @@ -33,6 +33,8 @@ #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" + const char* EXECUTOR_CLASS = "org/apache/doris/udf/UdfExecutor"; const char* EXECUTOR_CTOR_SIGNATURE = "([B)V"; const char* EXECUTOR_EVALUATE_SIGNATURE = "(Ljava/util/Map;Ljava/util/Map;)J"; @@ -206,4 +208,6 @@ int UDFTableFunction::get_value(MutableColumnPtr& column, int max_step) { forward(max_step); return max_step; } + +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/udf_table_function.h b/be/src/vec/exprs/table_function/udf_table_function.h index b9707bf069398d..c5f55a1c0cb024 100644 --- a/be/src/vec/exprs/table_function/udf_table_function.h +++ b/be/src/vec/exprs/table_function/udf_table_function.h @@ -26,6 +26,7 @@ #include "vec/functions/array/function_array_utils.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" class UDFTableFunction final : public TableFunction { ENABLE_FACTORY_CREATOR(UDFTableFunction); @@ -94,4 +95,5 @@ class UDFTableFunction final : public TableFunction { size_t _array_offset = 0; // start offset of array[row_idx] }; +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode.cpp b/be/src/vec/exprs/table_function/vexplode.cpp index b3d3c770138044..feef58cd27726c 100644 --- a/be/src/vec/exprs/table_function/vexplode.cpp +++ b/be/src/vec/exprs/table_function/vexplode.cpp @@ -20,12 +20,10 @@ #include #include -#include #include "common/status.h" #include "vec/columns/column.h" #include "vec/columns/column_object.h" -#include "vec/common/string_ref.h" #include "vec/core/block.h" #include "vec/core/column_with_type_and_name.h" #include "vec/data_types/data_type.h" @@ -33,6 +31,7 @@ #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" VExplodeTableFunction::VExplodeTableFunction() { _fn_name = "vexplode"; @@ -124,4 +123,6 @@ int VExplodeTableFunction::get_value(MutableColumnPtr& column, int max_step) { forward(max_step); return max_step; } + +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode.h b/be/src/vec/exprs/table_function/vexplode.h index b59b9718ad54d1..17b67d07824fa0 100644 --- a/be/src/vec/exprs/table_function/vexplode.h +++ b/be/src/vec/exprs/table_function/vexplode.h @@ -17,18 +17,18 @@ #pragma once -#include +#include #include "common/status.h" #include "vec/data_types/data_type.h" #include "vec/exprs/table_function/table_function.h" #include "vec/functions/array/function_array_utils.h" -namespace doris { -namespace vectorized { +namespace doris::vectorized { +#include "common/compile_check_begin.h" + class Block; -} // namespace vectorized -} // namespace doris +} // namespace doris::vectorized namespace doris::vectorized { @@ -52,4 +52,5 @@ class VExplodeTableFunction : public TableFunction { size_t _array_offset; // start offset of array[row_idx] }; +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_bitmap.cpp b/be/src/vec/exprs/table_function/vexplode_bitmap.cpp index 5327c2e1633a09..b76d49d95a2b3a 100644 --- a/be/src/vec/exprs/table_function/vexplode_bitmap.cpp +++ b/be/src/vec/exprs/table_function/vexplode_bitmap.cpp @@ -21,7 +21,6 @@ #include #include -#include #include "common/status.h" #include "util/bitmap_value.h" @@ -36,6 +35,7 @@ #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" VExplodeBitmapTableFunction::VExplodeBitmapTableFunction() { _fn_name = "vexplode_bitmap"; @@ -126,7 +126,7 @@ int VExplodeBitmapTableFunction::get_value(MutableColumnPtr& column, int max_ste } auto origin_size = target->size(); target->resize(origin_size + max_step); - auto target_data = target->get_data().data(); + auto* target_data = target->get_data().data(); for (int i = 0; i < max_step; ++i) { target_data[i + origin_size] = **_cur_iter; ++(*_cur_iter); @@ -135,4 +135,5 @@ int VExplodeBitmapTableFunction::get_value(MutableColumnPtr& column, int max_ste TableFunction::forward(max_step); return max_step; } +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_bitmap.h b/be/src/vec/exprs/table_function/vexplode_bitmap.h index 17c1070646bb87..74e16d5e4b1108 100644 --- a/be/src/vec/exprs/table_function/vexplode_bitmap.h +++ b/be/src/vec/exprs/table_function/vexplode_bitmap.h @@ -17,8 +17,7 @@ #pragma once -#include - +#include #include #include "common/status.h" @@ -26,13 +25,10 @@ #include "vec/data_types/data_type.h" #include "vec/exprs/table_function/table_function.h" -namespace doris { -namespace vectorized { -class Block; -} // namespace vectorized -} // namespace doris - namespace doris::vectorized { +#include "common/compile_check_begin.h" + +class Block; class VExplodeBitmapTableFunction final : public TableFunction { ENABLE_FACTORY_CREATOR(VExplodeBitmapTableFunction); @@ -60,4 +56,5 @@ class VExplodeBitmapTableFunction final : public TableFunction { ColumnPtr _value_column; }; +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_json_array.cpp b/be/src/vec/exprs/table_function/vexplode_json_array.cpp index 3c22ef4e078119..673ae0c9c266d3 100644 --- a/be/src/vec/exprs/table_function/vexplode_json_array.cpp +++ b/be/src/vec/exprs/table_function/vexplode_json_array.cpp @@ -18,16 +18,12 @@ #include "vec/exprs/table_function/vexplode_json_array.h" #include -#include #include -#include #include -#include +#include #include "common/status.h" -#include "util/jsonb_parser.h" -#include "util/jsonb_utils.h" #include "vec/columns/column.h" #include "vec/columns/column_nullable.h" #include "vec/columns/columns_number.h" @@ -38,6 +34,8 @@ #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" + template VExplodeJsonArrayTableFunction::VExplodeJsonArrayTableFunction() : TableFunction() { _fn_name = "vexplode_json_array"; @@ -155,4 +153,5 @@ template class VExplodeJsonArrayTableFunction; template class VExplodeJsonArrayTableFunction; template class VExplodeJsonArrayTableFunction; +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_json_array.h b/be/src/vec/exprs/table_function/vexplode_json_array.h index 28428b8f89f475..94378708f9e4a2 100644 --- a/be/src/vec/exprs/table_function/vexplode_json_array.h +++ b/be/src/vec/exprs/table_function/vexplode_json_array.h @@ -20,21 +20,19 @@ #include #include -#include #include #include #include "common/status.h" -#include "gutil/integral_types.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" #include "vec/common/string_ref.h" #include "vec/core/types.h" #include "vec/data_types/data_type.h" #include "vec/exprs/table_function/table_function.h" -#include "vec/functions/function_string.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" template struct ParsedData { @@ -50,7 +48,7 @@ struct ParsedData { int max_step) = 0; virtual void insert_many_same_value_from_parsed_data(MutableColumnPtr& column, int64_t cur_offset, int length) = 0; - const char* get_null_flag_address(int cur_offset) { + const char* get_null_flag_address(size_t cur_offset) { return reinterpret_cast(_values_null_flag.data() + cur_offset); } std::vector _values_null_flag; @@ -77,7 +75,8 @@ struct ParsedDataInt : public ParsedData { } } else if (v.IsDouble()) { auto value = v.GetDouble(); - if (value > MAX_VALUE) { + // target slot is int64(cast double to int64). so compare with int64_max + if (static_cast(value) > MAX_VALUE) { _backup_data[i] = MAX_VALUE; } else if (value < MIN_VALUE) { _backup_data[i] = MIN_VALUE; @@ -107,7 +106,8 @@ struct ParsedDataInt : public ParsedData { _backup_data[i] = static_cast(val).val(); } else if (val.isDouble()) { auto value = static_cast(val).val(); - if (value > MAX_VALUE) { + // target slot is int64(cast double to int64). so compare with int64_max + if (static_cast(value) > MAX_VALUE) { _backup_data[i] = MAX_VALUE; } else if (value < MIN_VALUE) { _backup_data[i] = MIN_VALUE; @@ -420,4 +420,5 @@ class VExplodeJsonArrayTableFunction final : public TableFunction { DataTypePtr _text_datatype; }; +#include "common/compile_check_end.h" } // namespace doris::vectorized \ No newline at end of file diff --git a/be/src/vec/exprs/table_function/vexplode_json_object.cpp b/be/src/vec/exprs/table_function/vexplode_json_object.cpp index 1981f48f62c71f..7db4da395aeae2 100644 --- a/be/src/vec/exprs/table_function/vexplode_json_object.cpp +++ b/be/src/vec/exprs/table_function/vexplode_json_object.cpp @@ -20,10 +20,10 @@ #include #include -#include #include "common/status.h" #include "vec/columns/column.h" +#include "vec/columns/column_struct.h" #include "vec/common/string_ref.h" #include "vec/core/block.h" #include "vec/core/column_with_type_and_name.h" @@ -31,6 +31,7 @@ #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" VExplodeJsonObjectTableFunction::VExplodeJsonObjectTableFunction() { _fn_name = "vexplode_json_object"; @@ -55,7 +56,7 @@ void VExplodeJsonObjectTableFunction::process_row(size_t row_idx) { StringRef text = _json_object_column->get_data_at(row_idx); if (text.data != nullptr) { JsonbDocument* doc = JsonbDocument::createDocument(text.data, text.size); - if (UNLIKELY(!doc || !doc->getValue())) { + if (!doc || !doc->getValue()) [[unlikely]] { // error jsonb, put null into output, cur_size = 0 , we will insert_default return; } @@ -64,18 +65,18 @@ void VExplodeJsonObjectTableFunction::process_row(size_t row_idx) { auto writer = std::make_unique(); if (value->isObject()) { _cur_size = value->length(); - ObjectVal* obj = (ObjectVal*)value; + auto* obj = (ObjectVal*)value; _object_pairs.first = ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); _object_pairs.second = ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); _object_pairs.first->reserve(_cur_size); _object_pairs.second->reserve(_cur_size); - for (auto it = obj->begin(); it != obj->end(); ++it) { - _object_pairs.first->insert_data(it->getKeyStr(), it->klen()); + for (auto& it : *obj) { + _object_pairs.first->insert_data(it.getKeyStr(), it.klen()); writer->reset(); - writer->writeValue(it->value()); - if (it->value()->isNull()) { + writer->writeValue(it.value()); + if (it.value()->isNull()) { _object_pairs.second->insert_default(); } else { const std::string_view& jsonb_value = std::string_view( @@ -157,4 +158,6 @@ int VExplodeJsonObjectTableFunction::get_value(MutableColumnPtr& column, int max forward(max_step); return max_step; } + +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_json_object.h b/be/src/vec/exprs/table_function/vexplode_json_object.h index 9173fd9cbace9d..c0ab5d148ccbc0 100644 --- a/be/src/vec/exprs/table_function/vexplode_json_object.h +++ b/be/src/vec/exprs/table_function/vexplode_json_object.h @@ -17,21 +17,15 @@ #pragma once -#include +#include #include "common/status.h" -#include "vec/columns/column_map.h" #include "vec/data_types/data_type.h" -#include "vec/data_types/data_type_array.h" -#include "vec/data_types/data_type_map.h" #include "vec/exprs/table_function/table_function.h" -#include "vec/functions/array/function_array_utils.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" class Block; -} // namespace doris::vectorized - -namespace doris::vectorized { // explode_json_object("{\"a\": 1, \"b\": 2}") -> // | key | value | @@ -56,4 +50,5 @@ class VExplodeJsonObjectTableFunction : public TableFunction { std::pair _object_pairs; // ColumnNullable }; +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_map.cpp b/be/src/vec/exprs/table_function/vexplode_map.cpp index ee88d9f07dfd49..a9b59f3c69ccad 100644 --- a/be/src/vec/exprs/table_function/vexplode_map.cpp +++ b/be/src/vec/exprs/table_function/vexplode_map.cpp @@ -20,17 +20,16 @@ #include #include -#include #include "common/status.h" #include "vec/columns/column.h" -#include "vec/common/string_ref.h" #include "vec/core/block.h" #include "vec/core/column_with_type_and_name.h" #include "vec/exprs/vexpr.h" #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" VExplodeMapTableFunction::VExplodeMapTableFunction() { _fn_name = "vexplode_map"; @@ -156,4 +155,6 @@ int VExplodeMapTableFunction::get_value(MutableColumnPtr& column, int max_step) forward(max_step); return max_step; } + +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_map.h b/be/src/vec/exprs/table_function/vexplode_map.h index c9756c9499bd8f..ea8e9584896445 100644 --- a/be/src/vec/exprs/table_function/vexplode_map.h +++ b/be/src/vec/exprs/table_function/vexplode_map.h @@ -17,21 +17,17 @@ #pragma once -#include +#include #include "common/status.h" #include "vec/columns/column_map.h" #include "vec/data_types/data_type.h" -#include "vec/data_types/data_type_array.h" -#include "vec/data_types/data_type_map.h" #include "vec/exprs/table_function/table_function.h" -#include "vec/functions/array/function_array_utils.h" namespace doris::vectorized { -class Block; -} // namespace doris::vectorized +#include "common/compile_check_begin.h" -namespace doris::vectorized { +class Block; struct ColumnMapExecutionData { public: @@ -66,4 +62,5 @@ class VExplodeMapTableFunction : public TableFunction { size_t _collection_offset; // start offset of array[row_idx] }; +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_numbers.cpp b/be/src/vec/exprs/table_function/vexplode_numbers.cpp index dbfb8d3edc1877..0c4c330f73c787 100644 --- a/be/src/vec/exprs/table_function/vexplode_numbers.cpp +++ b/be/src/vec/exprs/table_function/vexplode_numbers.cpp @@ -20,7 +20,6 @@ #include #include -#include #include "common/status.h" #include "runtime/runtime_state.h" @@ -36,6 +35,7 @@ #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" VExplodeNumbersTableFunction::VExplodeNumbersTableFunction() { _fn_name = "vexplode_numbers"; @@ -52,19 +52,25 @@ Status VExplodeNumbersTableFunction::process_init(Block* block, RuntimeState* st _value_column = block->get_by_position(value_column_idx).column; if (is_column_const(*_value_column)) { _cur_size = 0; - auto& column_nested = assert_cast(*_value_column).get_data_column_ptr(); + + // the argument columns -> Int32 + const auto& column_nested = + assert_cast(*_value_column).get_data_column_ptr(); if (column_nested->is_nullable()) { if (!column_nested->is_null_at(0)) { - _cur_size = assert_cast(column_nested.get()) - ->get_nested_column() - .get_int(0); + _cur_size = assert_cast( + assert_cast(column_nested.get()) + ->get_nested_column_ptr() + .get()) + ->get_element(0); } } else { - _cur_size = column_nested->get_int(0); + _cur_size = assert_cast(column_nested.get())->get_element(0); } + ((ColumnInt32*)_elements_column.get())->clear(); //_cur_size may be a negative number - _cur_size = std::max(0, _cur_size); + _cur_size = std::max(0L, _cur_size); if (_cur_size && _cur_size <= state->batch_size()) { // avoid elements_column too big or empty _is_const = true; // use const optimize @@ -96,17 +102,20 @@ void VExplodeNumbersTableFunction::get_same_many_values(MutableColumnPtr& column if (current_empty()) { column->insert_many_defaults(length); } else { + // for explode numbers, the argument is int32. so cast is safe. if (_is_nullable) { assert_cast( assert_cast(column.get())->get_nested_column_ptr().get()) - ->insert_many_vals(_cur_offset, length); + ->insert_many_vals(static_cast(_cur_offset), length); assert_cast( assert_cast(column.get())->get_null_map_column_ptr().get()) ->insert_many_defaults(length); } else { - assert_cast(column.get())->insert_many_vals(_cur_offset, length); + assert_cast(column.get()) + ->insert_many_vals(static_cast(_cur_offset), length); } } } +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_numbers.h b/be/src/vec/exprs/table_function/vexplode_numbers.h index dda4a047a2088c..403b87e2e1d274 100644 --- a/be/src/vec/exprs/table_function/vexplode_numbers.h +++ b/be/src/vec/exprs/table_function/vexplode_numbers.h @@ -17,9 +17,8 @@ #pragma once -#include - #include +#include #include "common/status.h" #include "vec/columns/column_nullable.h" @@ -29,10 +28,9 @@ #include "vec/exprs/table_function/table_function.h" namespace doris::vectorized { -class Block; -} // namespace doris::vectorized +#include "common/compile_check_begin.h" -namespace doris::vectorized { +class Block; class VExplodeNumbersTableFunction : public TableFunction { ENABLE_FACTORY_CREATOR(VExplodeNumbersTableFunction); @@ -92,4 +90,5 @@ class VExplodeNumbersTableFunction : public TableFunction { ColumnPtr _elements_column = ColumnInt32::create(); }; +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_split.cpp b/be/src/vec/exprs/table_function/vexplode_split.cpp index 51a95dbd5c6f21..950459f9b202c2 100644 --- a/be/src/vec/exprs/table_function/vexplode_split.cpp +++ b/be/src/vec/exprs/table_function/vexplode_split.cpp @@ -34,6 +34,7 @@ #include "vec/exprs/vexpr_context.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" VExplodeSplitTableFunction::VExplodeSplitTableFunction() { _fn_name = "vexplode_split"; @@ -156,4 +157,6 @@ int VExplodeSplitTableFunction::get_value(doris::vectorized::MutableColumnPtr& c TableFunction::forward(max_step); return max_step; } + +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/exprs/table_function/vexplode_split.h b/be/src/vec/exprs/table_function/vexplode_split.h index 089abe23dda140..860f7a7b087a71 100644 --- a/be/src/vec/exprs/table_function/vexplode_split.h +++ b/be/src/vec/exprs/table_function/vexplode_split.h @@ -19,7 +19,6 @@ #include #include -#include #include #include "common/status.h" @@ -28,6 +27,7 @@ #include "vec/exprs/table_function/table_function.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" class Block; template @@ -58,4 +58,5 @@ class VExplodeSplitTableFunction final : public TableFunction { StringRef _delimiter = {}; }; +#include "common/compile_check_end.h" } // namespace doris::vectorized