This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch dev-1.0.0
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit 3d1c4cf63f804a5ec1d1ae262334ee7c2f25d6f1
Author: Mingyu Chen <[email protected]>
AuthorDate: Fri Mar 11 17:23:47 2022 +0800

    [improvement] Avoid print large string in error log (#8436)
    
    1. Avoid print large string in error log
        If user load a unqualified large string, the all string will be saved 
in error log,
        so the error log is too big that can not be shown be using `show load 
warnings on "url"`.
        Err: `Got packet bigger than 'max_allowed_packet' bytes`
    
    2. Remove duplicate help doc
        Do not allow doc with same title, or error thrown when starting FE:
        `java.lang.IllegalArgumentException: Multiple entries with same key:`
---
 be/src/vec/common/string_ref.h                     |  3 ++
 be/src/vec/sink/vtablet_sink.cpp                   |  8 +--
 docs/.vuepress/sidebar/en.js                       |  1 -
 docs/.vuepress/sidebar/zh-CN.js                    |  1 -
 .../sql-functions/string-functions/coalesce.md     | 62 ---------------------
 .../sql-functions/string-functions/coalesce.md     | 63 ----------------------
 .../apache/doris/analysis/CreateFunctionStmt.java  |  2 +-
 7 files changed, 8 insertions(+), 132 deletions(-)

diff --git a/be/src/vec/common/string_ref.h b/be/src/vec/common/string_ref.h
index ebc4dcc..8f83d07 100644
--- a/be/src/vec/common/string_ref.h
+++ b/be/src/vec/common/string_ref.h
@@ -55,6 +55,9 @@ struct StringRef {
     std::string to_string() const { return std::string(data, size); }
     std::string_view to_string_view() const { return std::string_view(data, 
size); }
 
+    // this is just for show, eg. print data to error log, to avoid print 
large string.
+    std::string to_prefix(size_t length) const { return std::string(data, 
std::min(length, size)); }
+
     explicit operator std::string() const { return to_string(); }
 
     StringVal to_string_val() {
diff --git a/be/src/vec/sink/vtablet_sink.cpp b/be/src/vec/sink/vtablet_sink.cpp
index 25d6117..fc5079d 100644
--- a/be/src/vec/sink/vtablet_sink.cpp
+++ b/be/src/vec/sink/vtablet_sink.cpp
@@ -203,7 +203,7 @@ Status VOlapTableSink::_validate_data(RuntimeState* state, 
vectorized::Block* bl
                             fmt::format_to(error_msg, "{}",
                                            "the length of input is too long 
than schema. ");
                             fmt::format_to(error_msg, "column_name: {}; ", 
desc->col_name());
-                            fmt::format_to(error_msg, "input str: [{}] ", 
str_val.to_string());
+                            fmt::format_to(error_msg, "input str: [{}] ", 
str_val.to_prefix(10));
                             fmt::format_to(error_msg, "schema length: {}; ", 
desc->type().len);
                             fmt::format_to(error_msg, "actual length: {}; ", 
str_val.size);
                         } else if (str_val.size > MAX_SIZE_OF_VEC_STRING) {
@@ -211,9 +211,9 @@ Status VOlapTableSink::_validate_data(RuntimeState* state, 
vectorized::Block* bl
                                     error_msg, "{}",
                                     "the length of input string is too long 
than vec schema. ");
                             fmt::format_to(error_msg, "column_name: {}; ", 
desc->col_name());
-                            fmt::format_to(error_msg, "input str: [{}] ", 
str_val.to_string());
-                            fmt::format_to(error_msg, "schema length: {}; ",
-                                           MAX_SIZE_OF_VEC_STRING);
+                            fmt::format_to(error_msg, "input str: [{}] ", 
str_val.to_prefix(10));
+                            fmt::format_to(error_msg, "schema length: {}; ", 
desc->type().len);
+                            fmt::format_to(error_msg, "limit length: {}; ", 
MAX_SIZE_OF_VEC_STRING);
                             fmt::format_to(error_msg, "actual length: {}; ", 
str_val.size);
                         }
 
diff --git a/docs/.vuepress/sidebar/en.js b/docs/.vuepress/sidebar/en.js
index f64decb..941be11 100644
--- a/docs/.vuepress/sidebar/en.js
+++ b/docs/.vuepress/sidebar/en.js
@@ -341,7 +341,6 @@ module.exports = [
               "ascii",
               "bit_length",
               "char_length",
-              "coalesce",
               "concat",
               "concat_ws",
               "ends_with",
diff --git a/docs/.vuepress/sidebar/zh-CN.js b/docs/.vuepress/sidebar/zh-CN.js
index 8a4d21f..582407b 100644
--- a/docs/.vuepress/sidebar/zh-CN.js
+++ b/docs/.vuepress/sidebar/zh-CN.js
@@ -345,7 +345,6 @@ module.exports = [
               "ascii",
               "bit_length",
               "char_length",
-              "coalesce",
               "concat",
               "concat_ws",
               "ends_with",
diff --git a/docs/en/sql-reference/sql-functions/string-functions/coalesce.md 
b/docs/en/sql-reference/sql-functions/string-functions/coalesce.md
deleted file mode 100644
index 23fef73..0000000
--- a/docs/en/sql-reference/sql-functions/string-functions/coalesce.md
+++ /dev/null
@@ -1,62 +0,0 @@
----
-{
-    "title": "coalesce",
-    "language": "en"
-}
----
-
-<!-- 
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-# coalesce
-## Description
-### Syntax
-
-`VARCHAR coalesce(VARCHAR, ...)`
-`...`
-`INT coalesce(INT, ...)`
-
-` coalesce ` function will return the first not null value. If it's all value 
is null, return null
-
-## example
-
-```
-MySQL> select coalesce(1,null,2);
-+----------------------+
-| coalesce(1, NULL, 2) |
-+----------------------+
-|                    1 |
-+----------------------+
-
-MySQL> select coalesce(null,"asd",1);
-+--------------------------+
-| coalesce(NULL, 'asd', 1) |
-+--------------------------+
-| asd                      |
-+--------------------------+
-
-MySQL> select coalesce(null,null,null);
-+----------------------------+
-| coalesce(NULL, NULL, NULL) |
-+----------------------------+
-|                       NULL |
-+----------------------------+
-```
-## keyword
-coalesce
diff --git 
a/docs/zh-CN/sql-reference/sql-functions/string-functions/coalesce.md 
b/docs/zh-CN/sql-reference/sql-functions/string-functions/coalesce.md
deleted file mode 100644
index 0ea6c2a..0000000
--- a/docs/zh-CN/sql-reference/sql-functions/string-functions/coalesce.md
+++ /dev/null
@@ -1,63 +0,0 @@
----
-{
-    "title": "coalesce",
-    "language": "zh-CN"
-}
----
-
-<!-- 
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-# coalesce
-## description
-### Syntax
-
-`VARCHAR coalesce(VARCHAR, ...)`
-`...`
-`INT coalesce(INT, ...)`
-
-`coalesce`函数会返回第一个非NULL的值,若全部为NULL,则返回NULL
-
-## example
-
-```
-MySQL> select coalesce(1,null,2);
-+----------------------+
-| coalesce(1, NULL, 2) |
-+----------------------+
-|                    1 |
-+----------------------+
-
-MySQL> select coalesce(null,"asd",1);
-+--------------------------+
-| coalesce(NULL, 'asd', 1) |
-+--------------------------+
-| asd                      |
-+--------------------------+
-
-MySQL> select coalesce(null,null,null);
-+----------------------------+
-| coalesce(NULL, NULL, NULL) |
-+----------------------------+
-|                       NULL |
-+----------------------------+
-
-```
-## keyword
-coalesce
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateFunctionStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateFunctionStmt.java
index 6a5c18d..743fb21 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateFunctionStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateFunctionStmt.java
@@ -190,7 +190,7 @@ public class CreateFunctionStmt extends DdlStmt {
             try {
                 computeObjectChecksum();
             } catch (IOException | NoSuchAlgorithmException e) {
-                throw new AnalysisException("cannot to compute object's 
checksum");
+                throw new AnalysisException("cannot to compute object's 
checksum. err: " + e.getMessage());
             }
             String md5sum = properties.get(MD5_CHECKSUM);
             if (md5sum != null && !md5sum.equalsIgnoreCase(checksum)) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to