HappenLee commented on code in PR #14555:
URL: https://github.com/apache/doris/pull/14555#discussion_r1033109612
##########
be/src/vec/functions/function_string.h:
##########
@@ -1950,4 +1956,71 @@ struct SubReplaceFourImpl {
}
};
+class FunctionConvertTo : public IFunction {
+public:
+ static constexpr auto name = "convert_to";
+
+ static FunctionPtr create() { return
std::make_shared<FunctionConvertTo>(); }
+
+ String get_name() const override { return name; }
+
+ size_t get_number_of_arguments() const override { return 2; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const
override {
+ return std::make_shared<DataTypeString>();
+ }
+
+ bool use_default_implementation_for_constants() const override { return
true; }
+
+ Status execute_impl(FunctionContext* /*context*/, Block& block, const
ColumnNumbers& arguments,
+ size_t result, size_t input_rows_count) override {
+ ColumnPtr argument_columns[2];
+ argument_columns[0] =
+
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+ argument_columns[1] = block.get_by_position(arguments[1]).column;
+ const ColumnString* str_col = static_cast<const
ColumnString*>(argument_columns[0].get());
+ const auto& character_data =
+ reinterpret_cast<const
ColumnConst&>(*argument_columns[1]).get_data_at(0);
+ const auto& str_offset = str_col->get_offsets();
+ const auto& str_chars = str_col->get_chars();
+ auto col_res = ColumnString::create();
+ auto& res_offset = col_res->get_offsets();
+ auto& res_chars = col_res->get_chars();
+ res_offset.resize(input_rows_count);
+
+ if (character_data.to_string_view().compare("gbk") == 0) {
+ iconv_t cd = iconv_open("gb2312", "utf-8");
Review Comment:
maybe the variable should be function context, only judge one time
--
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]