github-advanced-security[bot] commented on code in PR #19615:
URL: https://github.com/apache/druid/pull/19615#discussion_r3455147948


##########
server/src/test/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinatorTest.java:
##########
@@ -632,6 +738,82 @@
     );
   }
 
+  /**
+   * When a REPLACE commits over an interval with already-published APPEND 
segments held under a REPLACE lock, the
+   * upgraded (re-versioned) copies must preserve their {@link 
DimensionValueSetShardSpec} so they remain prunable by
+   * the broker.
+   */
+  @Test
+  public void 
testCommitReplaceSegments_upgradedPublishedSegmentPreservesDimensionValueSetShardSpec()
+  {
+    final ReplaceTaskLock replaceLock = new ReplaceTaskLock("g1", 
Intervals.of("2023-01-01/2023-02-01"), "2023-02-01");
+
+    final Map<String, List<String>> partitionDimensionValues = 
ImmutableMap.of("tenant_id", ImmutableList.of("tenant_a"));
+    // A published APPEND segment carrying a DimensionValueSetShardSpec (as 
stamped at publish time by the streaming task).
+    final DataSegment appendSegment = new DataSegment(
+        "foo",
+        Intervals.of("2023-01-01/2023-01-02"),
+        "2023-01-01",
+        ImmutableMap.of("path", "a-0"),
+        ImmutableList.of("dim1"),
+        ImmutableList.of("m1"),
+        new DimensionValueSetShardSpec(0, 1, partitionDimensionValues),
+        9,
+        100
+    );

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [DataSegment.DataSegment](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11314)



##########
server/src/test/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinatorTest.java:
##########
@@ -632,6 +738,82 @@
     );
   }
 
+  /**
+   * When a REPLACE commits over an interval with already-published APPEND 
segments held under a REPLACE lock, the
+   * upgraded (re-versioned) copies must preserve their {@link 
DimensionValueSetShardSpec} so they remain prunable by
+   * the broker.
+   */
+  @Test
+  public void 
testCommitReplaceSegments_upgradedPublishedSegmentPreservesDimensionValueSetShardSpec()
+  {
+    final ReplaceTaskLock replaceLock = new ReplaceTaskLock("g1", 
Intervals.of("2023-01-01/2023-02-01"), "2023-02-01");
+
+    final Map<String, List<String>> partitionDimensionValues = 
ImmutableMap.of("tenant_id", ImmutableList.of("tenant_a"));
+    // A published APPEND segment carrying a DimensionValueSetShardSpec (as 
stamped at publish time by the streaming task).
+    final DataSegment appendSegment = new DataSegment(
+        "foo",
+        Intervals.of("2023-01-01/2023-01-02"),
+        "2023-01-01",
+        ImmutableMap.of("path", "a-0"),
+        ImmutableList.of("dim1"),
+        ImmutableList.of("m1"),
+        new DimensionValueSetShardSpec(0, 1, partitionDimensionValues),
+        9,
+        100
+    );
+    segmentSchemaTestUtils.insertUsedSegments(Set.of(appendSegment), 
Collections.emptyMap());
+    insertIntoUpgradeSegmentsTable(
+        Map.of(appendSegment, replaceLock),
+        derbyConnectorRule.metadataTablesConfigSupplier().get()
+    );
+
+    final Set<DataSegment> replacingSegments = new HashSet<>();
+    for (int i = 0; i < 4; i++) {
+      replacingSegments.add(
+          new DataSegment(
+              "foo",
+              Intervals.of("2023-01-01/2023-02-01"),
+              "2023-02-01",
+              ImmutableMap.of("path", "b-" + i),
+              ImmutableList.of("dim1"),
+              ImmutableList.of("m1"),
+              new NumberedShardSpec(i, 4),
+              9,
+              100
+          )

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [DataSegment.DataSegment](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11315)



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