This is an automated email from the ASF dual-hosted git repository.
jackietien 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 06810e69568 [IOTDB-6272] Fix wrong RealNumber check for PartialPath
06810e69568 is described below
commit 06810e69568fef23267813e1041432dbb752e8b8
Author: Liao Lanyu <[email protected]>
AuthorDate: Thu Dec 21 08:43:01 2023 +0800
[IOTDB-6272] Fix wrong RealNumber check for PartialPath
---
.../db/it/schema/IoTDBCreateTimeseriesIT.java | 4 +--
.../tsfile/read/common/parser/PathVisitor.java | 10 ++++++-
.../apache/iotdb/tsfile/read/common/PathTest.java | 32 ++++++++++++++++++++++
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBCreateTimeseriesIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBCreateTimeseriesIT.java
index e0ec131d89d..fe9832422c0 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBCreateTimeseriesIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBCreateTimeseriesIT.java
@@ -141,10 +141,10 @@ public class IoTDBCreateTimeseriesIT extends
AbstractSchemaIT {
}
String[] timeSeriesArray = {
- "root.sg.d.`a.b`", "root.sg.d.`a“(Φ)”b`", "root.sg.d.`a>b`",
+ "root.sg.d.`a.b`", "root.sg.d.`a“(Φ)”b`", "root.sg.d.`a>b`",
"root.sg.d.`0e38`"
};
String[] timeSeriesResArray = {
- "root.sg.d.`a.b`", "root.sg.d.`a“(Φ)”b`", "root.sg.d.`a>b`",
+ "root.sg.d.`a.b`", "root.sg.d.`a“(Φ)”b`", "root.sg.d.`a>b`",
"root.sg.d.`0e38`",
};
try (Connection connection = EnvFactory.getEnv().getConnection();
diff --git
a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
index e5a1514a41b..d45dd93c1aa 100644
---
a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
+++
b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
@@ -92,6 +92,14 @@ public class PathVisitor extends
PathParserBaseVisitor<String[]> {
break;
}
}
- return NumberUtils.isCreatable(str.substring(index));
+ if (index > 0 && (str.charAt(index) == 'e' || str.charAt(index) == 'E')) {
+ // first char encountered is e/E means the number is like: "000e38".(all
leading zeros before
+ // e/E)
+ return NumberUtils.isCreatable(str.substring(index - 1));
+ } else {
+ // parse the str after removing the leading zeros
+ // Numbers like 0000 and 00.12 can also be handled by this branch
+ return NumberUtils.isCreatable(str.substring(index));
+ }
}
}
diff --git
a/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
b/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
index a78f8132d47..99a4e1b7ed7 100644
---
a/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
+++
b/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
@@ -19,6 +19,7 @@
package org.apache.iotdb.tsfile.read.common;
import org.apache.iotdb.tsfile.exception.PathParseException;
+import org.apache.iotdb.tsfile.read.common.parser.PathVisitor;
import org.junit.Assert;
import org.junit.Test;
@@ -115,6 +116,18 @@ public class PathTest {
p = new Path("root.sg.contains", true);
Assert.assertEquals("root.sg", p.getDevice());
Assert.assertEquals("contains", p.getMeasurement());
+
+ p = new Path("root.sg.`0000`", true);
+ Assert.assertEquals("root.sg", p.getDevice());
+ Assert.assertEquals("`0000`", p.getMeasurement());
+
+ p = new Path("root.sg.`0e38`", true);
+ Assert.assertEquals("root.sg", p.getDevice());
+ Assert.assertEquals("`0e38`", p.getMeasurement());
+
+ p = new Path("root.sg.`00.12`", true);
+ Assert.assertEquals("root.sg", p.getDevice());
+ Assert.assertEquals("`00.12`", p.getMeasurement());
}
@Test
@@ -170,5 +183,24 @@ public class PathTest {
fail();
} catch (PathParseException ignored) {
}
+
+ try {
+ new Path("root.0e38", true);
+ fail();
+ } catch (PathParseException ignored) {
+ }
+
+ try {
+ new Path("root.0000", true);
+ fail();
+ } catch (PathParseException ignored) {
+ }
+ }
+
+ @Test
+ public void testRealNumber() {
+ Assert.assertTrue(PathVisitor.isRealNumber("0e38"));
+ Assert.assertTrue(PathVisitor.isRealNumber("0000"));
+ Assert.assertTrue(PathVisitor.isRealNumber("00.12"));
}
}