linrrzqqq commented on code in PR #56367:
URL: https://github.com/apache/doris/pull/56367#discussion_r2374626930
##########
be/src/vec/functions/function_string.h:
##########
@@ -4957,6 +4957,103 @@ class FunctionXPathString : public IFunction {
}
};
+class FunctionMakeSet : public IFunction {
+public:
+ static constexpr auto name = "make_set";
+ static FunctionPtr create() { return std::make_shared<FunctionMakeSet>(); }
+ String get_name() const override { return name; }
+ size_t get_number_of_arguments() const override { return 0; }
+ bool is_variadic() const override { return true; }
+ bool use_default_implementation_for_nulls() const override { return false;
}
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
+ if (arguments[0].get()->is_nullable()) {
+ return make_nullable(std::make_shared<DataTypeString>());
+ }
+ return std::make_shared<DataTypeString>();
+ }
+
+ Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
+ uint32_t result, size_t input_rows_count) const
override {
+ auto res_col = ColumnString::create();
+ auto null_map = ColumnUInt8::create();
+
+ const auto& [bit_col, bit_const] =
+ unpack_if_const(block.get_by_position(arguments[0]).column);
+
+ if (bit_const) {
+ if (bit_col->is_null_at(0)) {
+ res_col->insert_many_defaults(input_rows_count);
+ null_map->insert_many_vals(1, input_rows_count);
+ } else {
+ const int64_t bit_data =
+ assert_cast<const
ColumnInt64*>(bit_col.get())->get_element(0);
+ vector_execute<true>(block, arguments, input_rows_count,
*res_col, bit_data,
+ null_map->get_data());
+ }
+ } else if (const auto* bit_data =
check_and_get_column<ColumnNullable>(bit_col.get())) {
+ null_map->insert_range_from(bit_data->get_null_map_column(), 0,
input_rows_count);
+ vector_execute<false>(block, arguments, input_rows_count, *res_col,
+ assert_cast<const
ColumnInt64&>(bit_data->get_nested_column()),
+ null_map->get_data());
+
+ } else {
+ null_map->get_data().resize_fill(input_rows_count, 0);
+ vector_execute<false>(block, arguments, input_rows_count, *res_col,
+ assert_cast<const
ColumnInt64&>(*bit_col.get()),
+ null_map->get_data());
+ }
+
+ if (block.get_by_position(arguments[0]).type.get()->is_nullable()) {
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(res_col),
std::move(null_map)));
+ } else {
+ block.replace_by_position(result, std::move(res_col));
+ }
+ return Status::OK();
+ }
+
+private:
+ template <bool bit_const>
+ void vector_execute(const Block& block, const ColumnNumbers& arguments,
size_t input_rows_count,
+ ColumnString& res_col, const ColumnInt64& bit_col,
+ PaddedPODArray<uint8_t>& null_map) const {
+ if constexpr (bit_const) {
+ int64_t bit = bit_col.get_element(0);
+ for (size_t i = 0; i < input_rows_count; ++i) {
+ execute_one_row(block, arguments, res_col, bit, i);
+ }
+ } else {
+ for (size_t i = 0; i < input_rows_count; ++i) {
+ if (null_map[i]) {
+ res_col.insert_default();
+ continue;
+ }
+ execute_one_row(block, arguments, res_col,
bit_col.get_element(i), i);
+ }
+ }
+ }
+
+ void execute_one_row(const Block& block, const ColumnNumbers& arguments,
ColumnString& res_col,
+ int64_t bit, int row_num) const {
+ static constexpr char SEPARATOR = ',';
+ int64_t pos = __builtin_ffs(bit);
+ ColumnString::Chars data;
+ while (pos != 0 && pos < arguments.size() && bit != 0) {
+ auto col = block.get_by_position(arguments[pos]).column;
+ if (!col->is_null_at(row_num)) {
+ auto s_ref = col->get_data_at(row_num);
+ if (data.size()) {
Review Comment:
应该以 `,` 开头, fixed
--
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]