You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by jf...@apache.org on 2020/05/02 07:47:58 UTC
[incubator-iotdb] branch bugfix/iotdb-grafana-boolean created (now
a1c2b78)
This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a change to branch bugfix/iotdb-grafana-boolean
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at a1c2b78 Added workaround when doing Aggregation over boolean Series.
This branch includes the following new commits:
new a1c2b78 Added workaround when doing Aggregation over boolean Series.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-iotdb] 01/01: Added workaround when doing Aggregation
over boolean Series.
Posted by jf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a commit to branch bugfix/iotdb-grafana-boolean
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit a1c2b782c59cfdc7b1cdd5cf08c152bee55603bf
Author: Julian Feinauer <j....@pragmaticminds.de>
AuthorDate: Sat May 2 09:47:35 2020 +0200
Added workaround when doing Aggregation over boolean Series.
---
.../iotdb/web/grafana/dao/impl/BasicDaoImpl.java | 21 +++++++++++++++++++++
grafana/src/main/resources/application.properties | 2 +-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java b/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java
index 7af408f..d1574d8 100644
--- a/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java
+++ b/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java
@@ -98,8 +98,28 @@ public class BasicDaoImpl implements BasicDao {
return (List<String>) jdbcTemplate.execute(connectionCallback);
}
+ /**
+ * Note: If the query fails this could be due to AGGREGATIION like AVG on booleayn field.
+ * Thus, we then do a retry with FIRST aggregation.
+ * This should be solved better in the long run.
+ */
@Override
public List<TimeValues> querySeries(String s, Pair<ZonedDateTime, ZonedDateTime> timeRange) {
+ try {
+ return querySeriesInternal(s, timeRange, function);
+ } catch (Exception e) {
+ logger.info("Execution failed, trying now with FIRST Function!");
+ // Try it with FIRST
+ try {
+ return querySeriesInternal(s, timeRange, "FIRST");
+ } catch (Exception e2) {
+ logger.warn("Even FIRST query did not succeed, returning NULL now", e2);
+ return null;
+ }
+ }
+ }
+
+ public List<TimeValues> querySeriesInternal(String s, Pair<ZonedDateTime, ZonedDateTime> timeRange, String function) {
Long from = zonedCovertToLong(timeRange.left);
Long to = zonedCovertToLong(timeRange.right);
final long hours = Duration.between(timeRange.left, timeRange.right).toHours();
@@ -126,6 +146,7 @@ public class BasicDaoImpl implements BasicDao {
rows = jdbcTemplate.query(sql, new TimeValuesRowMapper(columnName));
} catch (Exception e) {
logger.error(e.getMessage());
+ throw new RuntimeException("Query did not sucees", e);
}
return rows;
}
diff --git a/grafana/src/main/resources/application.properties b/grafana/src/main/resources/application.properties
index 7847a8a..eee8d0a 100644
--- a/grafana/src/main/resources/application.properties
+++ b/grafana/src/main/resources/application.properties
@@ -32,4 +32,4 @@ isDownSampling=true
interval=1m
# aggregation function to use to downsampling the data
# COUNT, FIRST_VALUE, LAST_VALUE, MAX_TIME, MAX_VALUE, AVG, MIN_TIME, MIN_VALUE, NOW, SUM
-function=avg
\ No newline at end of file
+function=AVG
\ No newline at end of file