This is an automated email from the ASF dual-hosted git repository.
bossenti pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new c9494b51a9 refactor: minor code & logging improvements (#2761)
c9494b51a9 is described below
commit c9494b51a9d4b4b7638bc75ce838d157064da46c
Author: Tim <[email protected]>
AuthorDate: Wed Apr 24 08:08:48 2024 +0200
refactor: minor code & logging improvements (#2761)
* refactor: minor code & logging improvements
* refactor: improve log statements
---
.../dataexplorer/query/AutoAggregationHandler.java | 14 ++++++++------
.../dataexplorer/query/DataExplorerQueryExecutor.java | 4 ++--
2 files changed, 10 insertions(+), 8 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);
}
}
}
diff --git
a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java
b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java
index c28c949780..205046303a 100644
---
a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java
+++
b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java
@@ -95,12 +95,12 @@ public abstract class DataExplorerQueryExecutor<X, W> {
public SpQueryResult executeQuery(X query,
boolean ignoreMissingValues) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Data Lake Query " + asQueryString(query));
+ LOG.debug("Data Lake Query {}", asQueryString(query));
}
W result = executeQuery(query);
if (LOG.isDebugEnabled()) {
- LOG.debug("Data Lake Query Result: " + result.toString());
+ LOG.debug("Data Lake Query Result: {}", result.toString());
}
return postQuery(result, ignoreMissingValues);