You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2021/11/23 05:13:38 UTC
[iotdb] branch rel/0.12 updated: [IOTDB-2050] Fix Time Filter doesn't take effect in last query bug (#4449)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.12 by this push:
new 0358756 [IOTDB-2050] Fix Time Filter doesn't take effect in last query bug (#4449)
0358756 is described below
commit 0358756c58c80eba76fe5cc7508cf5113fd40058
Author: Jackie Tien <Ja...@foxmail.com>
AuthorDate: Tue Nov 23 13:12:56 2021 +0800
[IOTDB-2050] Fix Time Filter doesn't take effect in last query bug (#4449)
---
.../iotdb/db/query/executor/LastQueryExecutor.java | 4 +-
.../IoTDBLastQueryWithTimeFilterIT.java | 118 +++++++++++++++++++++
2 files changed, 120 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/query/executor/LastQueryExecutor.java b/server/src/main/java/org/apache/iotdb/db/query/executor/LastQueryExecutor.java
index 5216943..a5745b3 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/executor/LastQueryExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/executor/LastQueryExecutor.java
@@ -177,7 +177,7 @@ public class LastQueryExecutor {
for (int i = 0; i < nonCachedPaths.size(); i++) {
QueryDataSource dataSource =
QueryResourceManager.getInstance()
- .getQueryDataSource(nonCachedPaths.get(i), context, null);
+ .getQueryDataSource(nonCachedPaths.get(i), context, filter);
LastPointReader lastReader =
new LastPointReader(
nonCachedPaths.get(i),
@@ -186,7 +186,7 @@ public class LastQueryExecutor {
context,
dataSource,
Long.MAX_VALUE,
- null);
+ filter);
readerList.add(lastReader);
}
} finally {
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastQueryWithTimeFilterIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastQueryWithTimeFilterIT.java
new file mode 100644
index 0000000..f748f89
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastQueryWithTimeFilterIT.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db.integration;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.jdbc.Config;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import static org.junit.Assert.fail;
+
+public class IoTDBLastQueryWithTimeFilterIT {
+
+ private static final String[] dataSet1 =
+ new String[] {"INSERT INTO root.sg1.d1(timestamp,s1) " + "values(1, 1)", "flush"};
+
+ private static final String TIMESEIRES_STR = "timeseries";
+ private static final String VALUE_STR = "value";
+ private static boolean enableLastCache;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvironmentUtils.closeStatMonitor();
+ EnvironmentUtils.envSetUp();
+ enableLastCache = IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled();
+ IoTDBDescriptor.getInstance().getConfig().setEnableLastCache(false);
+ Class.forName(Config.JDBC_DRIVER_NAME);
+ prepareData();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ IoTDBDescriptor.getInstance().getConfig().setEnableLastCache(enableLastCache);
+ EnvironmentUtils.cleanEnv();
+ }
+
+ @Test
+ public void lastWithTimeFilterTest() throws Exception {
+
+ try (Connection connection =
+ DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+
+ statement.execute("select last s1 from root.sg1.d1 where time > 1");
+
+ ResultSet resultSet = statement.getResultSet();
+ int cnt = 0;
+ while (resultSet.next()) {
+ fail();
+ }
+ Assert.assertEquals(0, cnt);
+ }
+ }
+
+ @Test
+ public void lastWithoutTimeFilterTest() throws Exception {
+
+ String[] retArray =
+ new String[] {
+ "root.sg1.d1.s1,1.0",
+ };
+ try (Connection connection =
+ DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+
+ statement.execute("select last s1 from root.sg1.d1");
+
+ ResultSet resultSet = statement.getResultSet();
+ int cnt = 0;
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESEIRES_STR) + "," + resultSet.getString(VALUE_STR);
+ Assert.assertEquals(retArray[cnt], ans);
+ cnt++;
+ }
+ Assert.assertEquals(retArray.length, cnt);
+ }
+ }
+
+ private static void prepareData() {
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+
+ for (String sql : dataSet1) {
+ statement.execute(sql);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}