kfaraz commented on code in PR #13967:
URL: https://github.com/apache/druid/pull/13967#discussion_r1170090201


##########
server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java:
##########
@@ -161,6 +161,25 @@ public int markSegments(final Collection<SegmentId> 
segmentIds, final boolean us
     );
   }
 
+  public int markSegmentAsHandedOff(final SegmentId segmentId)
+  {
+    final String dataSource = segmentId.getDataSource();
+
+    final PreparedBatch batch =
+        handle.prepareBatch(
+            StringUtils.format(
+                "UPDATE %s SET handed_off = true WHERE datasource = ? AND id = 
?",
+                dbTables.getSegmentsTable()
+            )
+        );
+
+    batch.add(dataSource, segmentId.toString());
+
+    final int[] segmentChanges = batch.execute();
+
+    return segmentChanges.length;

Review Comment:
   This should return 1 or 0 based on whether the update was actually 
successful. Use `computeNumChangedSegments`, if applicable.



##########
server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java:
##########
@@ -161,6 +161,25 @@ public int markSegments(final Collection<SegmentId> 
segmentIds, final boolean us
     );
   }
 
+  public int markSegmentAsHandedOff(final SegmentId segmentId)
+  {
+    final String dataSource = segmentId.getDataSource();
+
+    final PreparedBatch batch =

Review Comment:
   You need not create a batch if it is a single UPDATE statement.



##########
processing/src/main/java/org/apache/druid/query/QueryException.java:
##########
@@ -79,6 +79,7 @@ public class QueryException extends RuntimeException 
implements SanitizableExcep
   public static final String SQL_PARSE_FAILED_ERROR_CODE = "SQL parse failed";
   public static final String PLAN_VALIDATION_FAILED_ERROR_CODE = "Plan 
validation failed";
   public static final String SQL_QUERY_UNSUPPORTED_ERROR_CODE = "SQL query is 
unsupported";
+  public static final String UNAVAILABLE_SEGMENTS_ERROR_CODE = "Unavailable 
segments";

Review Comment:
   ```suggestion
     public static final String UNAVAILABLE_SEGMENTS_ERROR_CODE = "Some 
segments are unavailable";
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to