You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "Mryange (via GitHub)" <gi...@apache.org> on 2023/04/08 06:25:52 UTC

[GitHub] [doris] Mryange opened a new pull request, #18486: [feature](planner) Add new parameters to 'trim'.

Mryange opened a new pull request, #18486:
URL: https://github.com/apache/doris/pull/18486

   # Proposed changes
   
   ```
   mysql> SELECT trim('ababccaab','ab') str;
   +------+
   | str  |
   +------+
   | cca  |
   +------+
   ```
   
   ## Checklist(Required)
   
   * [ ] Does it affect the original behavior
   * [ ] Has unit tests been added
   * [ ] Has document been added or modified
   * [ ] Does it need to update dependencies
   * [ ] Is this PR support rollback (If NO, please explain WHY)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502792696

   run clickbench


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange closed pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange closed pull request #18486: [feature](function) Add new parameters to 'trim'.
URL: https://github.com/apache/doris/pull/18486


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502631143

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1504547922

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1500869193

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] zclllyybb commented on a diff in pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "zclllyybb (via GitHub)" <gi...@apache.org>.
zclllyybb commented on code in PR #18486:
URL: https://github.com/apache/doris/pull/18486#discussion_r1161284731


##########
be/src/vec/functions/function_string.cpp:
##########
@@ -311,38 +311,128 @@ struct InitcapImpl {
 struct NameTrim {
     static constexpr auto name = "trim";
 };
-
 struct NameLTrim {
     static constexpr auto name = "ltrim";
 };
-
 struct NameRTrim {
     static constexpr auto name = "rtrim";
 };
-
 template <bool is_ltrim, bool is_rtrim>
-struct TrimImpl {
-    static Status vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets,
+struct TrimUtil {
+    static Status vector(const ColumnString::Chars& str_data,
+                         const ColumnString::Offsets& str_offsets, const StringRef& rhs,
                          ColumnString::Chars& res_data, ColumnString::Offsets& res_offsets) {
-        size_t offset_size = offsets.size();
-        res_offsets.resize(offsets.size());
-
+        size_t offset_size = str_offsets.size();
+        res_offsets.resize(str_offsets.size());
         for (size_t i = 0; i < offset_size; ++i) {
-            const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]);
-            ColumnString::Offset size = offsets[i] - offsets[i - 1];
+            const char* raw_str = reinterpret_cast<const char*>(&str_data[str_offsets[i - 1]]);
+            ColumnString::Offset size = str_offsets[i] - str_offsets[i - 1];
             StringRef str(raw_str, size);
             if constexpr (is_ltrim) {
-                str = simd::VStringFunctions::ltrim(str);
+                str = simd::VStringFunctions::ltrim(str, rhs);
             }
             if constexpr (is_rtrim) {
-                str = simd::VStringFunctions::rtrim(str);
+                str = simd::VStringFunctions::rtrim(str, rhs);
             }
             StringOP::push_value_string(std::string_view((char*)str.data, str.size), i, res_data,
                                         res_offsets);
         }
         return Status::OK();
     }
 };
+// This is an implementation of a parameter for the Trim function.
+template <bool is_ltrim, bool is_rtrim, typename Name>
+struct Trim1Impl {
+    static constexpr auto name = Name::name;
+
+    static DataTypes get_variadic_argument_types() { return {std::make_shared<DataTypeString>()}; }
+
+    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count) {
+        const ColumnPtr column = block.get_by_position(arguments[0]).column;
+        if (const ColumnString* col = check_and_get_column<ColumnString>(column.get())) {
+            auto col_res = ColumnString::create();
+            StringRef rhs(" ", 1);
+            TrimUtil<is_ltrim, is_rtrim>::vector(col->get_chars(), col->get_offsets(), rhs,
+                                                 col_res->get_chars(), col_res->get_offsets());
+            block.replace_by_position(result, std::move(col_res));
+        } else {
+            return Status::RuntimeError("Illegal column {} of argument of function {}",
+                                        block.get_by_position(arguments[0]).column->get_name(),
+                                        name);
+        }
+        return Status::OK();
+    }
+};
+
+// This is an implementation of two parameters for the Trim function.
+template <bool is_ltrim, bool is_rtrim, typename Name>
+struct Trim2Impl {
+    static constexpr auto name = Name::name;
+
+    static DataTypes get_variadic_argument_types() {
+        return {std::make_shared<DataTypeString>(), std::make_shared<DataTypeString>()};
+    }
+
+    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count) {
+        const ColumnPtr column = block.get_by_position(arguments[0]).column;
+        const auto& [rcol, right_const] =
+                unpack_if_const(block.get_by_position(arguments[1]).column);

Review Comment:
   what if `column` is const but `rcol` not?



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1501317875

   run buildall


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502876884

   run feut


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1500804827

   run buildall


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502575254

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] zclllyybb commented on a diff in pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "zclllyybb (via GitHub)" <gi...@apache.org>.
zclllyybb commented on code in PR #18486:
URL: https://github.com/apache/doris/pull/18486#discussion_r1162888820


##########
be/src/vec/functions/function_string.cpp:
##########
@@ -311,38 +311,133 @@ struct InitcapImpl {
 struct NameTrim {
     static constexpr auto name = "trim";
 };
-
 struct NameLTrim {
     static constexpr auto name = "ltrim";
 };
-
 struct NameRTrim {
     static constexpr auto name = "rtrim";
 };
-
 template <bool is_ltrim, bool is_rtrim>
-struct TrimImpl {
-    static Status vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets,
+struct TrimUtil {
+    static Status vector(const ColumnString::Chars& str_data,
+                         const ColumnString::Offsets& str_offsets, const StringRef& rhs,
                          ColumnString::Chars& res_data, ColumnString::Offsets& res_offsets) {
-        size_t offset_size = offsets.size();
-        res_offsets.resize(offsets.size());
-
+        size_t offset_size = str_offsets.size();
+        res_offsets.resize(str_offsets.size());
         for (size_t i = 0; i < offset_size; ++i) {
-            const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]);
-            ColumnString::Offset size = offsets[i] - offsets[i - 1];
+            const char* raw_str = reinterpret_cast<const char*>(&str_data[str_offsets[i - 1]]);
+            ColumnString::Offset size = str_offsets[i] - str_offsets[i - 1];
             StringRef str(raw_str, size);
             if constexpr (is_ltrim) {
-                str = simd::VStringFunctions::ltrim(str);
+                str = simd::VStringFunctions::ltrim(str, rhs);
             }
             if constexpr (is_rtrim) {
-                str = simd::VStringFunctions::rtrim(str);
+                str = simd::VStringFunctions::rtrim(str, rhs);
             }
             StringOP::push_value_string(std::string_view((char*)str.data, str.size), i, res_data,
                                         res_offsets);
         }
         return Status::OK();
     }
 };
+// This is an implementation of a parameter for the Trim function.
+template <bool is_ltrim, bool is_rtrim, typename Name>
+struct Trim1Impl {
+    static constexpr auto name = Name::name;
+
+    static DataTypes get_variadic_argument_types() { return {std::make_shared<DataTypeString>()}; }
+
+    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count) {
+        const ColumnPtr column = block.get_by_position(arguments[0]).column;
+        if (const ColumnString* col = check_and_get_column<ColumnString>(column.get())) {
+            auto col_res = ColumnString::create();
+            char blank[] = " ";
+            StringRef rhs(blank, 1);
+            TrimUtil<is_ltrim, is_rtrim>::vector(col->get_chars(), col->get_offsets(), rhs,
+                                                 col_res->get_chars(), col_res->get_offsets());
+            block.replace_by_position(result, std::move(col_res));
+        } else {
+            return Status::RuntimeError("Illegal column {} of argument of function {}",
+                                        block.get_by_position(arguments[0]).column->get_name(),
+                                        name);
+        }
+        return Status::OK();
+    }
+};
+
+// This is an implementation of two parameters for the Trim function.
+template <bool is_ltrim, bool is_rtrim, typename Name>
+struct Trim2Impl {
+    static constexpr auto name = Name::name;
+
+    static DataTypes get_variadic_argument_types() {
+        return {std::make_shared<DataTypeString>(), std::make_shared<DataTypeString>()};
+    }
+
+    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count) {
+        const ColumnPtr column = block.get_by_position(arguments[0]).column;
+        const auto& [rcol, right_const] =
+                unpack_if_const(block.get_by_position(arguments[1]).column);

Review Comment:
   since you have set `get_arguments_that_are_always_constant`, use `static_cast<ColumnConst>->get_data_column_ptr` to avoid RTTI check.



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502571095

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502570483

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502567567

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1500828135

   run buildall


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1500805214

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1500814111

   run buildall


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1501071388

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502904172

   run beut


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1502629877

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1501318987

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1500828602

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1500814507

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #18486: [feature](planner) Add new parameters to 'trim'.

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1501070943

   run buildall


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] zclllyybb commented on a diff in pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "zclllyybb (via GitHub)" <gi...@apache.org>.
zclllyybb commented on code in PR #18486:
URL: https://github.com/apache/doris/pull/18486#discussion_r1161284731


##########
be/src/vec/functions/function_string.cpp:
##########
@@ -311,38 +311,128 @@ struct InitcapImpl {
 struct NameTrim {
     static constexpr auto name = "trim";
 };
-
 struct NameLTrim {
     static constexpr auto name = "ltrim";
 };
-
 struct NameRTrim {
     static constexpr auto name = "rtrim";
 };
-
 template <bool is_ltrim, bool is_rtrim>
-struct TrimImpl {
-    static Status vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets,
+struct TrimUtil {
+    static Status vector(const ColumnString::Chars& str_data,
+                         const ColumnString::Offsets& str_offsets, const StringRef& rhs,
                          ColumnString::Chars& res_data, ColumnString::Offsets& res_offsets) {
-        size_t offset_size = offsets.size();
-        res_offsets.resize(offsets.size());
-
+        size_t offset_size = str_offsets.size();
+        res_offsets.resize(str_offsets.size());
         for (size_t i = 0; i < offset_size; ++i) {
-            const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]);
-            ColumnString::Offset size = offsets[i] - offsets[i - 1];
+            const char* raw_str = reinterpret_cast<const char*>(&str_data[str_offsets[i - 1]]);
+            ColumnString::Offset size = str_offsets[i] - str_offsets[i - 1];
             StringRef str(raw_str, size);
             if constexpr (is_ltrim) {
-                str = simd::VStringFunctions::ltrim(str);
+                str = simd::VStringFunctions::ltrim(str, rhs);
             }
             if constexpr (is_rtrim) {
-                str = simd::VStringFunctions::rtrim(str);
+                str = simd::VStringFunctions::rtrim(str, rhs);
             }
             StringOP::push_value_string(std::string_view((char*)str.data, str.size), i, res_data,
                                         res_offsets);
         }
         return Status::OK();
     }
 };
+// This is an implementation of a parameter for the Trim function.
+template <bool is_ltrim, bool is_rtrim, typename Name>
+struct Trim1Impl {
+    static constexpr auto name = Name::name;
+
+    static DataTypes get_variadic_argument_types() { return {std::make_shared<DataTypeString>()}; }
+
+    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count) {
+        const ColumnPtr column = block.get_by_position(arguments[0]).column;
+        if (const ColumnString* col = check_and_get_column<ColumnString>(column.get())) {
+            auto col_res = ColumnString::create();
+            StringRef rhs(" ", 1);
+            TrimUtil<is_ltrim, is_rtrim>::vector(col->get_chars(), col->get_offsets(), rhs,
+                                                 col_res->get_chars(), col_res->get_offsets());
+            block.replace_by_position(result, std::move(col_res));
+        } else {
+            return Status::RuntimeError("Illegal column {} of argument of function {}",
+                                        block.get_by_position(arguments[0]).column->get_name(),
+                                        name);
+        }
+        return Status::OK();
+    }
+};
+
+// This is an implementation of two parameters for the Trim function.
+template <bool is_ltrim, bool is_rtrim, typename Name>
+struct Trim2Impl {
+    static constexpr auto name = Name::name;
+
+    static DataTypes get_variadic_argument_types() {
+        return {std::make_shared<DataTypeString>(), std::make_shared<DataTypeString>()};
+    }
+
+    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count) {
+        const ColumnPtr column = block.get_by_position(arguments[0]).column;
+        const auto& [rcol, right_const] =
+                unpack_if_const(block.get_by_position(arguments[1]).column);

Review Comment:
   what if `column` is const but `rcol` not?



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #18486: [feature](function) Add new parameters to 'trim'.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18486:
URL: https://github.com/apache/doris/pull/18486#issuecomment-1504541685

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org