This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 637bf1b Fix incorrect error msg in avg() query
637bf1b is described below
commit 637bf1b2740e458ce39631a946525c7b2ec8ace2
Author: wshao08 <[email protected]>
AuthorDate: Thu May 21 16:18:12 2020 +0800
Fix incorrect error msg in avg() query
---
.../apache/iotdb/db/query/aggregation/impl/AvgAggrResult.java | 7 +++++++
.../java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java | 9 +++++++++
2 files changed, 16 insertions(+)
diff --git
a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/AvgAggrResult.java
b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/AvgAggrResult.java
index e93d0e6..2eaf975 100644
---
a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/AvgAggrResult.java
+++
b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/AvgAggrResult.java
@@ -25,6 +25,7 @@ import java.nio.ByteBuffer;
import org.apache.iotdb.db.query.aggregation.AggregateResult;
import org.apache.iotdb.db.query.aggregation.AggregationType;
import org.apache.iotdb.db.query.reader.series.IReaderByTimestamp;
+import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.file.metadata.statistics.Statistics;
import org.apache.iotdb.tsfile.read.common.BatchData;
@@ -60,6 +61,12 @@ public class AvgAggrResult extends AggregateResult {
@Override
public void updateResultFromStatistics(Statistics statistics) {
long preCnt = cnt;
+ if (statistics.getType().equals(TSDataType.BOOLEAN)) {
+ throw new StatisticsClassException("Boolean statistics does not support:
avg");
+ }
+ if (statistics.getType().equals(TSDataType.TEXT)) {
+ throw new StatisticsClassException("Binary statistics does not support:
avg");
+ }
cnt += statistics.getCount();
avg = avg * ((double) preCnt / cnt) + ((double) statistics.getCount() /
cnt)
* statistics.getSumValue() / statistics.getCount();
diff --git
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
index f603efd..26bc141 100644
---
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
+++
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
@@ -507,6 +507,15 @@ public class IoTDBAggregationIT {
Assert.assertEquals("500: Unsupported data type in aggregation SUM :
BOOLEAN",
e.getMessage());
}
+ try {
+ statement.execute("SELECT avg(status) FROM root.ln.wf01.wt01");
+ ResultSet resultSet = statement.getResultSet();
+ resultSet.next();
+ fail();
+ } catch (Exception e) {
+ Assert.assertEquals("500: Boolean statistics does not support: avg",
+ e.getMessage());
+ }
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());