You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/05/31 10:19:07 UTC

[iotdb] branch IOTDB-3358 created (now 05f63d12d6)

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

haonan pushed a change to branch IOTDB-3358
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 05f63d12d6 [IOTDB-3358] Fix error message of insert wrong type of data by sql is meaningless

This branch includes the following new commits:

     new 05f63d12d6 [IOTDB-3358] Fix error message of insert wrong type of data by sql is meaningless

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: [IOTDB-3358] Fix error message of insert wrong type of data by sql is meaningless

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch IOTDB-3358
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 05f63d12d607b738774328e9b9bd4b2535b7c404
Author: HTHou <hh...@outlook.com>
AuthorDate: Tue May 31 18:18:53 2022 +0800

    [IOTDB-3358] Fix error message of insert wrong type of data by sql is meaningless
---
 .../org/apache/iotdb/db/utils/CommonUtils.java     | 30 +++++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
index cd218ce637..1c7f8d7a3b 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
@@ -52,17 +52,39 @@ public class CommonUtils {
         case BOOLEAN:
           return parseBoolean(value);
         case INT32:
-          return Integer.parseInt(StringUtils.trim(value));
+          try {
+            return Integer.parseInt(StringUtils.trim(value));
+          } catch (NumberFormatException e) {
+            throw new NumberFormatException(
+                "data type is not consistent, input " + value + ", registered " + dataType);
+          }
         case INT64:
-          return Long.parseLong(StringUtils.trim(value));
+          try {
+            return Long.parseLong(StringUtils.trim(value));
+          } catch (NumberFormatException e) {
+            throw new NumberFormatException(
+                "data type is not consistent, input " + value + ", registered " + dataType);
+          }
         case FLOAT:
-          float f = Float.parseFloat(value);
+          float f;
+          try {
+            f = Float.parseFloat(value);
+          } catch (NumberFormatException e) {
+            throw new NumberFormatException(
+                "data type is not consistent, input " + value + ", registered " + dataType);
+          }
           if (Float.isInfinite(f)) {
             throw new NumberFormatException("The input float value is Infinity");
           }
           return f;
         case DOUBLE:
-          double d = Double.parseDouble(value);
+          double d;
+          try {
+            d = Double.parseDouble(value);
+          } catch (NumberFormatException e) {
+            throw new NumberFormatException(
+                "data type is not consistent, input " + value + ", registered " + dataType);
+          }
           if (Double.isInfinite(d)) {
             throw new NumberFormatException("The input double value is Infinity");
           }