This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new a4a3bdbc98 NIFI-10451 Updated QuestDB Status History Rollover to work 
with version 6
a4a3bdbc98 is described below

commit a4a3bdbc9814bb5e91bba871f4a43914c26a26ba
Author: Bence Simon <[email protected]>
AuthorDate: Wed Sep 7 22:39:34 2022 +0200

    NIFI-10451 Updated QuestDB Status History Rollover to work with version 6
    
    This closes #6374
    
    Co-authored-by: David Handermann <[email protected]>
    Signed-off-by: David Handermann <[email protected]>
---
 .../status/history/EmbeddedQuestDbRolloverHandler.java           | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandler.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandler.java
index fbb8128ed0..b0437346cc 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandler.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandler.java
@@ -19,8 +19,11 @@ package org.apache.nifi.controller.status.history;
 import io.questdb.cairo.sql.Record;
 import io.questdb.cairo.sql.RecordCursor;
 import io.questdb.cairo.sql.RecordCursorFactory;
+import io.questdb.griffin.CompiledQuery;
 import io.questdb.griffin.SqlCompiler;
 import io.questdb.griffin.SqlExecutionContext;
+import io.questdb.mp.SCSequence;
+import io.questdb.mp.TimeoutBlockingWaitStrategy;
 import org.apache.nifi.controller.status.history.questdb.QuestDbContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,6 +35,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
 
 /**
@@ -44,7 +48,7 @@ public class EmbeddedQuestDbRolloverHandler implements 
Runnable {
     private static final DateTimeFormatter DATE_FORMATTER = 
DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneOffset.UTC);
 
     // Drop keyword is intentionally not uppercase as the query parser only 
recognizes it in this way
-    private static final String DELETION_QUERY = "ALTER TABLE %s drop 
PARTITION '%s'";
+    private static final String DELETION_QUERY = "ALTER TABLE %s DROP 
PARTITION LIST '%s'";
     // 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)";
 
@@ -91,7 +95,8 @@ public class EmbeddedQuestDbRolloverHandler implements 
Runnable {
 
     private void deletePartition(final CharSequence tableName, final String 
partition) {
         try (final SqlCompiler compiler = dbContext.getCompiler()) {
-            compiler.compile(String.format(DELETION_QUERY, new 
Object[]{tableName, partition}), dbContext.getSqlExecutionContext());
+            final CompiledQuery compile = 
compiler.compile(String.format(DELETION_QUERY, tableName, partition), 
dbContext.getSqlExecutionContext());
+            compile.execute(new SCSequence(new TimeoutBlockingWaitStrategy(5, 
TimeUnit.SECONDS)));
         } catch (final Exception e) {
             LOGGER.error("Dropping partition " + partition + " of table " + 
tableName + " failed", e);
         }

Reply via email to