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/04/13 13:59:59 UTC

[iotdb] branch rel/0.13 updated: [To rel/0.13][IOTDB-2903] Fix last value fetch failure during show timesereis (#5505)

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

haonan pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.13 by this push:
     new e7505cc4bb [To rel/0.13][IOTDB-2903] Fix last value fetch failure during show timesereis (#5505)
e7505cc4bb is described below

commit e7505cc4bb125c80a28d1df10ab260f889198f52
Author: Marcos_Zyk <38...@users.noreply.github.com>
AuthorDate: Wed Apr 13 21:59:53 2022 +0800

    [To rel/0.13][IOTDB-2903] Fix last value fetch failure during show timesereis (#5505)
---
 .../iotdb/db/integration/IoTDBMetadataFetchIT.java | 38 ++++++++++++++++++++++
 .../db/metadata/lastCache/LastCacheManager.java    |  6 ++--
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
index 52210d2ec9..4f6cd885a9 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
@@ -623,4 +623,42 @@ public class IoTDBMetadataFetchIT {
 
     Assert.assertEquals(expected, actual);
   }
+
+  @Test
+  @Category({LocalStandaloneTest.class, ClusterTest.class, RemoteTest.class})
+  public void showLatestTimeseriesTest() throws SQLException {
+    try (Connection connection = EnvFactory.getEnv().getConnection();
+        Statement statement = connection.createStatement()) {
+
+      statement.execute("insert into root.ln.wf01.wt01(time, status) values(1, 1)");
+      statement.execute("insert into root.ln.wf01.wt01(time, temperature) values(2, 1)");
+      String sql = "show latest timeseries root.ln.wf01.wt01.*";
+      Set<String> standard =
+          new HashSet<>(
+              Arrays.asList(
+                  "root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,null,null,",
+                  "root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,"));
+      try {
+        boolean hasResultSet = statement.execute(sql);
+        if (hasResultSet) {
+          try (ResultSet resultSet = statement.getResultSet()) {
+            ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+            while (resultSet.next()) {
+              StringBuilder builder = new StringBuilder();
+              for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+                builder.append(resultSet.getString(i)).append(",");
+              }
+              String string = builder.toString();
+              Assert.assertTrue(standard.contains(string));
+              standard.remove(string);
+            }
+            assertEquals(0, standard.size());
+          }
+        }
+      } catch (SQLException e) {
+        logger.error("showTimeseriesTest() failed", e);
+        fail(e.getMessage());
+      }
+    }
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/lastCache/LastCacheManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/lastCache/LastCacheManager.java
index 6f57d912f0..117f5cec07 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/lastCache/LastCacheManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/lastCache/LastCacheManager.java
@@ -224,12 +224,12 @@ public class LastCacheManager {
         // because LastPointReader will do itself sort logic instead of depending on fillOrderIndex.
         QueryDataSource dataSource =
             QueryResourceManager.getInstance()
-                .getQueryDataSource(node.getPartialPath(), queryContext, null, false);
+                .getQueryDataSource(node.getMeasurementPath(), queryContext, null, false);
         Set<String> measurementSet = new HashSet<>();
-        measurementSet.add(node.getPartialPath().getFullPath());
+        measurementSet.add(node.getName());
         LastPointReader lastReader =
             new LastPointReader(
-                node.getPartialPath(),
+                node.getMeasurementPath(),
                 node.getSchema().getType(),
                 measurementSet,
                 queryContext,