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


##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/CompactionTaskTest.java:
##########
@@ -2272,6 +2550,57 @@
         .build();
   }
 
+  /**
+   * A segment whose index reports the given projections and nothing else, so 
only projection analysis does any work.
+   */
+  private static Pair<DataSegment, 
java.util.function.Supplier<ResourceHolder<QueryableIndex>>> 
segmentWithProjections(
+      Interval interval,
+      String... projectionNames
+  )
+  {
+    final List<AggregateProjectionMetadata> projectionMetadata = new 
ArrayList<>();
+    for (String projectionName : projectionNames) {
+      projectionMetadata.add(
+          new AggregateProjectionMetadata(
+              new AggregateProjectionSchema(
+                  projectionName,
+                  null,
+                  null,
+                  null,
+                  ImmutableList.of("string_dim_0"),
+                  new AggregatorFactory[]{new CountAggregatorFactory("cnt")},
+                  ImmutableList.of(OrderBy.ascending("string_dim_0"))
+              ),
+              1
+          )
+      );
+    }
+
+    final ColumnFormat columnFormat = Mockito.mock(ColumnFormat.class);
+    
Mockito.lenient().when(columnFormat.getColumnSchema(ArgumentMatchers.anyString()))
+           .thenAnswer(invocation -> new 
StringDimensionSchema(invocation.getArgument(0)));
+    final BaseColumnHolder columnHolder = Mockito.mock(BaseColumnHolder.class);
+    
Mockito.lenient().when(columnHolder.getColumnFormat()).thenReturn(columnFormat);
+
+    final QueryableIndex projectionIndex = Mockito.mock(QueryableIndex.class);
+    
Mockito.lenient().when(projectionIndex.getColumnHolder(ArgumentMatchers.anyString())).thenReturn(columnHolder);
+
+    final QueryableIndex index = Mockito.mock(QueryableIndex.class);
+    Mockito.lenient().when(index.getMetadata())
+           .thenReturn(new Metadata(null, null, null, null, null, null, 
projectionMetadata, null));
+    Mockito.lenient().when(index.getOrdering()).thenReturn(ImmutableList.of());
+    Mockito.lenient().when(index.getAvailableDimensions()).thenReturn(new 
ListIndexed<>());
+    
Mockito.lenient().when(index.getProjectionQueryableIndex(ArgumentMatchers.anyString())).thenReturn(projectionIndex);
+
+    final DataSegment segment = DataSegment.builder()

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



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