zclllyybb commented on code in PR #33272: URL: https://github.com/apache/doris/pull/33272#discussion_r1554582545
########## be/src/vec/functions/function_string.h: ########## @@ -294,6 +294,62 @@ struct SubstringUtil { } }; +class FunctionStrcmp : public IFunction { +public: + static constexpr auto name = "strcmp"; + + static FunctionPtr create() { return std::make_shared<FunctionStrcmp>(); } + + 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<DataTypeInt16>(); + } + + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, + size_t result, size_t input_rows_count) const override { + const auto& arg0_column = + assert_cast<const ColumnString&>(*block.get_by_position(arguments[0]).column); + const auto& arg1_column = + assert_cast<const ColumnString&>(*block.get_by_position(arguments[1]).column); + + auto result_column = ColumnInt16::create(input_rows_count); + auto& result_data = result_column->get_data(); + auto null_column = ColumnUInt8::create(input_rows_count); + auto& null_map = null_column->get_data(); + + for (int row = 0; row < input_rows_count; row++) { + null_map[row] = false; + if (arg0_column.is_nullable() || arg1_column.is_nullable()) { + null_map[row] = true; + continue; + } + + auto arg0 = arg0_column.get_data_at(row).to_string(); Review Comment: no need to convert to string. compare them directly ########## be/src/vec/functions/function_string.h: ########## @@ -294,6 +294,62 @@ struct SubstringUtil { } }; +class FunctionStrcmp : public IFunction { +public: + static constexpr auto name = "strcmp"; + + static FunctionPtr create() { return std::make_shared<FunctionStrcmp>(); } + + 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<DataTypeInt16>(); + } + + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, + size_t result, size_t input_rows_count) const override { + const auto& arg0_column = Review Comment: deal the const logic ########## be/src/vec/functions/function_string.h: ########## @@ -294,6 +294,62 @@ struct SubstringUtil { } }; +class FunctionStrcmp : public IFunction { +public: + static constexpr auto name = "strcmp"; + + static FunctionPtr create() { return std::make_shared<FunctionStrcmp>(); } + + 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<DataTypeInt16>(); + } + + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, + size_t result, size_t input_rows_count) const override { + const auto& arg0_column = + assert_cast<const ColumnString&>(*block.get_by_position(arguments[0]).column); + const auto& arg1_column = + assert_cast<const ColumnString&>(*block.get_by_position(arguments[1]).column); + + auto result_column = ColumnInt16::create(input_rows_count); + auto& result_data = result_column->get_data(); + auto null_column = ColumnUInt8::create(input_rows_count); + auto& null_map = null_column->get_data(); + + for (int row = 0; row < input_rows_count; row++) { + null_map[row] = false; + if (arg0_column.is_nullable() || arg1_column.is_nullable()) { Review Comment: no this ########## be/src/vec/functions/function_string.h: ########## @@ -294,6 +294,62 @@ struct SubstringUtil { } }; +class FunctionStrcmp : public IFunction { +public: + static constexpr auto name = "strcmp"; + + static FunctionPtr create() { return std::make_shared<FunctionStrcmp>(); } + + 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<DataTypeInt16>(); Review Comment: check nullable property and wrap it. ########## regression-test/suites/query_p0/sql_functions/string_functions/test_string_function.groovy: ########## Review Comment: delete the regression-test cases but add them to be-ut -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org