You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/17 00:49:50 UTC

[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #7017: [IOTDB-4133] Throw illegal path exception contains number which has been surrounded with quote

JackieTien97 commented on code in PR #7017:
URL: https://github.com/apache/iotdb/pull/7017#discussion_r947357310


##########
tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java:
##########
@@ -64,12 +64,28 @@ private String parseNodeName(PathParser.NodeNameContext ctx) {
     if (nodeName.startsWith(TsFileConstant.BACK_QUOTE_STRING)
         && nodeName.endsWith(TsFileConstant.BACK_QUOTE_STRING)) {
       String unWrapped = nodeName.substring(1, nodeName.length() - 1);
-      if (StringUtils.isNumeric(unWrapped)
+      if (isRealNumber(unWrapped)
           || !TsFileConstant.IDENTIFIER_PATTERN.matcher(unWrapped).matches()) {
         return nodeName;
       }
       return unWrapped;
     }
     return nodeName;
   }
+
+  /** Return true if the str is a real number. Examples: 1.0; +1.0; -1.0; 0011; 011e3; +23e-3 */
+  public static boolean isRealNumber(String str) {
+    if (str.startsWith("+")) {
+      return NumberUtils.isCreatable(str.substring(1));
+    }
+    int index = 0;
+    // remove zeros
+    for (int i = 0, n = str.length(); i < n; i++) {
+      if (str.charAt(i) != '0') {
+        index = i;
+        break;
+      }
+    }
+    return NumberUtils.isCreatable(str.substring(index));
+  }

Review Comment:
   duplicated with previous, and it seems that `+0001` and `-00001` won't be considered



-- 
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: reviews-unsubscribe@iotdb.apache.org

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