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 85fa188ed1 [IOTDB-4325] NaN and Infinity will be regard as positive
Infinity in where clause in 0.14.0 (#7226)
85fa188ed1 is described below
commit 85fa188ed1a9a3f60854de4c9ab2d4fbc394463b
Author: Liao Lanyu <[email protected]>
AuthorDate: Mon Sep 5 15:13:12 2022 +0800
[IOTDB-4325] NaN and Infinity will be regard as positive Infinity in where
clause in 0.14.0 (#7226)
---
.../java/org/apache/iotdb/db/it/IoTDBFilterIT.java | 119 +++++++++++++++++++++
.../org/apache/iotdb/db/it/IoTDBNestedQueryIT.java | 2 +-
.../binary/CompareBinaryColumnTransformer.java | 12 ++-
3 files changed, 127 insertions(+), 6 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
new file mode 100644
index 0000000000..76662fb1b4
--- /dev/null
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
@@ -0,0 +1,119 @@
+/*
+ * 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.it;
+
+import org.apache.iotdb.it.env.ConfigFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBFilterIT {
+ protected static final int ITERATION_TIMES = 10;
+
+ protected static boolean enableSeqSpaceCompaction;
+ protected static boolean enableUnseqSpaceCompaction;
+ protected static boolean enableCrossSpaceCompaction;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ enableSeqSpaceCompaction =
ConfigFactory.getConfig().isEnableSeqSpaceCompaction();
+ enableUnseqSpaceCompaction =
ConfigFactory.getConfig().isEnableUnseqSpaceCompaction();
+ enableCrossSpaceCompaction =
ConfigFactory.getConfig().isEnableCrossSpaceCompaction();
+ ConfigFactory.getConfig().setEnableSeqSpaceCompaction(false);
+ ConfigFactory.getConfig().setEnableUnseqSpaceCompaction(false);
+ ConfigFactory.getConfig().setEnableCrossSpaceCompaction(false);
+ ConfigFactory.getConfig()
+ .setUdfCollectorMemoryBudgetInMB(5)
+ .setUdfTransformerMemoryBudgetInMB(5)
+ .setUdfReaderMemoryBudgetInMB(5);
+ EnvFactory.getEnv().initBeforeClass();
+ createTimeSeries();
+ generateData();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvFactory.getEnv().cleanAfterClass();
+
ConfigFactory.getConfig().setEnableSeqSpaceCompaction(enableSeqSpaceCompaction);
+
ConfigFactory.getConfig().setEnableUnseqSpaceCompaction(enableUnseqSpaceCompaction);
+
ConfigFactory.getConfig().setEnableCrossSpaceCompaction(enableCrossSpaceCompaction);
+ }
+
+ private static void createTimeSeries() {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.execute("SET STORAGE GROUP TO root.vehicle");
+ statement.execute(
+ "create TIMESERIES root.vehicle.testNaN.d1 with
datatype=DOUBLE,encoding=PLAIN");
+ statement.execute(
+ "create TIMESERIES root.vehicle.testNaN.d2 with
datatype=DOUBLE,encoding=PLAIN");
+ } catch (SQLException throwable) {
+ fail(throwable.getMessage());
+ }
+ }
+
+ private static void generateData() {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ for (int i = 0; i < ITERATION_TIMES; i++) {
+ statement.execute(
+ String.format(
+ "insert into root.vehicle.testNaN(timestamp,d1,d2)
values(%d,%d,%d)", i, i, i));
+ }
+ } catch (SQLException throwable) {
+ fail(throwable.getMessage());
+ }
+ }
+
+ @Test
+ public void testFilterNaN() {
+ String sqlStr = "select d1 from root.vehicle.testNaN where d1/d2 > 0";
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ ResultSet resultSet = statement.executeQuery(sqlStr);
+
+ int count = 0;
+ while (resultSet.next()) {
+ ++count;
+ }
+
+ // 0.0/0.0 is NaN which should not be kept.
+ assertEquals(ITERATION_TIMES - 1, count);
+ } catch (SQLException throwable) {
+ fail(throwable.getMessage());
+ }
+ }
+}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java
index 3acd717f29..9eb5f56376 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java
@@ -108,7 +108,7 @@ public class IoTDBNestedQueryIT {
"insert into root.vehicle.d1(timestamp,s1,s2,s3)
values(%d,%d,%d,%s)", i, i, i, i));
statement.execute(
(String.format(
- "insert into root.vehicle.d2(timestamp,s1,s2)
values(%d,%d,%d)", i, i, i, i)));
+ "insert into root.vehicle.d2(timestamp,s1,s2)
values(%d,%d,%d)", i, i, i)));
}
} catch (SQLException throwable) {
fail(throwable.getMessage());
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/transformation/dag/column/binary/CompareBinaryColumnTransformer.java
b/server/src/main/java/org/apache/iotdb/db/mpp/transformation/dag/column/binary/CompareBinaryColumnTransformer.java
index f184289e3b..3055275213 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/transformation/dag/column/binary/CompareBinaryColumnTransformer.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/transformation/dag/column/binary/CompareBinaryColumnTransformer.java
@@ -53,11 +53,13 @@ public abstract class CompareBinaryColumnTransformer
extends BinaryColumnTransfo
leftTransformer.getType().getBoolean(leftColumn, i),
rightTransformer.getType().getBoolean(rightColumn, i)));
} else {
- flag =
- transform(
- compare(
- leftTransformer.getType().getDouble(leftColumn, i),
- rightTransformer.getType().getDouble(rightColumn, i)));
+ double left = leftTransformer.getType().getDouble(leftColumn, i);
+ double right = rightTransformer.getType().getDouble(rightColumn, i);
+ if (Double.isNaN(left) || Double.isNaN(right)) {
+ flag = false;
+ } else {
+ flag = transform(compare(left, right));
+ }
}
returnType.writeBoolean(builder, flag);
} else {