simonbence commented on a change in pull request #4883:
URL: https://github.com/apache/nifi/pull/4883#discussion_r592150063
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandler.java
##########
@@ -48,16 +47,22 @@
// Distinct keyword is not recognized if the date mapping is not within an
inner query
static final String SELECTION_QUERY = "SELECT DISTINCT * FROM (SELECT
(to_str(capturedAt, 'yyyy-MM-dd')) AS partitionName FROM %s)";
- static final DateTimeFormatter DATE_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault());
+ DateTimeFormatter DATE_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC"));
- private final QuestDbContext dbContext;
+ private final Supplier<ZonedDateTime> timeSource;
private final List<String> tables = new ArrayList<>();
private final int daysToKeepData;
+ private final QuestDbContext dbContext;
- public EmbeddedQuestDbRolloverHandler(final Collection<String> tables,
final int daysToKeepData, final QuestDbContext dbContext) {
+ EmbeddedQuestDbRolloverHandler(final Supplier<ZonedDateTime> timeSource,
final Collection<String> tables, final int daysToKeepData, final QuestDbContext
dbContext) {
+ this.timeSource = timeSource;
this.tables.addAll(tables);
- this.dbContext = dbContext;
this.daysToKeepData = daysToKeepData;
+ this.dbContext = dbContext;
+ }
+
+ public EmbeddedQuestDbRolloverHandler(final Collection<String> tables,
final int daysToKeepData, final QuestDbContext dbContext) {
+ this(() -> ZonedDateTime.now(), tables, daysToKeepData, dbContext);
Review comment:
Yes, that is deliberate: QuestDB works with UTC time internally. This
applies to the part where the DB decides in which partition the row should be
stored. Here we need to figure out the name (based on date) of the last
partition we need to keep. Thus we get the zone-correct time for the beginning
of the covered range and convert it into UTC. Based on that we get the name of
the given partition.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]