You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by bo...@apache.org on 2024/04/23 08:17:13 UTC
(streampipes) 01/01: refactor: minor code & logging improvements
This is an automated email from the ASF dual-hosted git repository.
bossenti pushed a commit to branch improve-auto-aggregation-handler
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 7dd50c442fde5318cb66a3a5936e9c7d52095edf
Author: bossenti <bo...@posteo.de>
AuthorDate: Tue Apr 23 10:16:50 2024 +0200
refactor: minor code & logging improvements
---
.../dataexplorer/query/AutoAggregationHandler.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/AutoAggregationHandler.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/AutoAggregationHandler.java
index 68bf23171a..071d7a64d2 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/AutoAggregationHandler.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/AutoAggregationHandler.java
@@ -51,8 +51,10 @@ public class AutoAggregationHandler {
private static final String TIMESTAMP_FIELD = "time";
private static final String COMMA = ",";
- private final SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- private final SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ // Date format for ISO 8601 timestamps with milliseconds
+ private final SimpleDateFormat isoFormatWithMillis = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ // Date format for ISO 8601 timestamps without milliseconds
+ private final SimpleDateFormat isoFormatOnlySeconds = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
private final IDataExplorerQueryManagement dataLakeQueryManagement;
private final ProvidedRestQueryParams queryParams;
@@ -91,7 +93,7 @@ public class AutoAggregationHandler {
return disableAutoAgg(this.queryParams);
}
} catch (ParseException e) {
- e.printStackTrace();
+ LOG.error("Parsing of timestamp failed during auto aggregation of query parameters: {}", e.getMessage());
}
return null;
}
@@ -144,7 +146,7 @@ public class AutoAggregationHandler {
List<SelectColumn> columns =
Arrays.stream(rawQuery.split(COMMA))
.map(SelectColumn::fromApiQueryString)
- .collect(Collectors.toList());
+ .toList();
return columns.stream()
.map(SelectColumn::getOriginalField)
.collect(Collectors.joining(COMMA));
@@ -172,9 +174,9 @@ public class AutoAggregationHandler {
private Date tryParseDate(String v) throws ParseException {
try {
- return dateFormat1.parse(v);
+ return isoFormatWithMillis.parse(v);
} catch (ParseException e) {
- return dateFormat2.parse(v);
+ return isoFormatOnlySeconds.parse(v);
}
}
}