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

qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b98a8cd5c [IOTDB-3358] Fix error message of insert wrong type of data 
by sql is meaningless (#6099)
0b98a8cd5c is described below

commit 0b98a8cd5c0d62c5defa5d0956c5e584ab849ee7
Author: Haonan <[email protected]>
AuthorDate: Tue May 31 20:23:10 2022 +0800

    [IOTDB-3358] Fix error message of insert wrong type of data by sql is 
meaningless (#6099)
---
 .../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");
           }

Reply via email to