suneet-s commented on code in PR #12185:
URL: https://github.com/apache/druid/pull/12185#discussion_r844154208


##########
integration-tests/src/test/java/org/apache/druid/tests/coordinator/duty/ITAutoCompactionTest.java:
##########
@@ -110,6 +118,226 @@ public void setup() throws Exception
     fullDatasourceName = "wikipedia_index_test_" + UUID.randomUUID() + 
config.getExtraDatasourceNameSuffix();
   }
 
+  @Test
+  public void 
testAutoCompactionRowWithMetricAndRowWithoutMetricShouldPreserveExistingMetrics()
 throws Exception
+  {
+    // added = null, count = 2, sum_added = 62, quantilesDoublesSketch = 2, 
thetaSketch = 2, HLLSketchBuild = 2
+    loadData(INDEX_TASK_WITH_ROLLUP_FOR_PRESERVE_METRICS);
+    // added = 31, count = null, sum_added = null, quantilesDoublesSketch = 
null, thetaSketch = null, HLLSketchBuild = null
+    loadData(INDEX_TASK_WITHOUT_ROLLUP_FOR_PRESERVE_METRICS);
+    try (final Closeable ignored = unloader(fullDatasourceName)) {
+      final List<String> intervalsBeforeCompaction = 
coordinator.getSegmentIntervals(fullDatasourceName);
+      intervalsBeforeCompaction.sort(null);
+      // 2 segments across 1 days...
+      verifySegmentsCount(2);
+      ArrayList<Object> nullList = new ArrayList<Object>();
+      nullList.add(null);
+      Map<String, Object> expectedResult = ImmutableMap.of(
+          "%%FIELD_TO_QUERY%%", "added",
+          "%%EXPECTED_COUNT_RESULT%%", 2,
+          "%%EXPECTED_SCAN_RESULT%%", 
ImmutableList.of(ImmutableMap.of("events", ImmutableList.of(nullList)), 
ImmutableMap.of("events", ImmutableList.of(ImmutableList.of(31))))
+      );
+      verifyQuery(INDEX_ROLLUP_QUERIES_RESOURCE, expectedResult);
+      expectedResult = ImmutableMap.of(
+          "%%FIELD_TO_QUERY%%", "count",
+          "%%EXPECTED_COUNT_RESULT%%", 2,
+          "%%EXPECTED_SCAN_RESULT%%", 
ImmutableList.of(ImmutableMap.of("events", 
ImmutableList.of(ImmutableList.of(2))), ImmutableMap.of("events", 
ImmutableList.of(nullList)))
+      );
+      verifyQuery(INDEX_ROLLUP_QUERIES_RESOURCE, expectedResult);
+      expectedResult = ImmutableMap.of(
+          "%%FIELD_TO_QUERY%%", "sum_added",
+          "%%EXPECTED_COUNT_RESULT%%", 2,
+          "%%EXPECTED_SCAN_RESULT%%", 
ImmutableList.of(ImmutableMap.of("events", 
ImmutableList.of(ImmutableList.of(62))), ImmutableMap.of("events", 
ImmutableList.of(nullList)))
+      );
+      verifyQuery(INDEX_ROLLUP_QUERIES_RESOURCE, expectedResult);

Review Comment:
   This had me confused. Reading the code, it looked like the same query was 
being run multiple times with different expected results. The variableName 
`expectedResult` is kinda off-putting since it isn't replacing just the 
results. `FIELD_TO_QUERY` is part of the query. I think we could use a better 
variable name here.
   
   Also, nitpicking: have you considered using all 3 fields in 1 query instead 
of issuing 3 queries?



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